From patchwork Fri Mar 22 20:36:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Khoroshilov X-Patchwork-Id: 2322481 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 21E23400E6 for ; Fri, 22 Mar 2013 20:45:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1422937Ab3CVUpr (ORCPT ); Fri, 22 Mar 2013 16:45:47 -0400 Received: from mail.ispras.ru ([83.149.199.45]:38692 "EHLO mail.ispras.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1422946Ab3CVUpr (ORCPT ); Fri, 22 Mar 2013 16:45:47 -0400 X-Greylist: delayed 531 seconds by postgrey-1.27 at vger.kernel.org; Fri, 22 Mar 2013 16:45:47 EDT Received: from localhost.localdomain (ppp91-79-114-102.pppoe.mtu-net.ru [91.79.114.102]) by mail.ispras.ru (Postfix) with ESMTPSA id B3ABF540154; Sat, 23 Mar 2013 00:36:52 +0400 (MSK) From: Alexey Khoroshilov To: "J. Bruce Fields" , Trond Myklebust Cc: Alexey Khoroshilov , linux-nfs@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org Subject: [PATCH] SUNRPC/cache: add module_put() on error path in cache_open() Date: Sat, 23 Mar 2013 00:36:44 +0400 Message-Id: <1363984604-17739-1-git-send-email-khoroshilov@ispras.ru> X-Mailer: git-send-email 1.7.9.5 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org If kmalloc() fails in cache_open(), module cd->owner left locked. The patch adds module_put(cd->owner) on this path. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov --- net/sunrpc/cache.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c index 25d58e76..1d3c514 100644 --- a/net/sunrpc/cache.c +++ b/net/sunrpc/cache.c @@ -986,8 +986,10 @@ static int cache_open(struct inode *inode, struct file *filp, nonseekable_open(inode, filp); if (filp->f_mode & FMODE_READ) { rp = kmalloc(sizeof(*rp), GFP_KERNEL); - if (!rp) + if (!rp) { + module_put(cd->owner); return -ENOMEM; + } rp->offset = 0; rp->q.reader = 1; atomic_inc(&cd->readers);