From patchwork Wed Oct 10 10:32:54 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Constantine Shulyupin X-Patchwork-Id: 1572851 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 991B640135 for ; Wed, 10 Oct 2012 10:35:06 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TLtb7-0007d7-DU; Wed, 10 Oct 2012 10:33:05 +0000 Received: from oproxy9.bluehost.com ([2605:dc00:100:2::a2]) by merlin.infradead.org with smtp (Exim 4.76 #1 (Red Hat Linux)) id 1TLtb3-0007cI-CP for linux-arm-kernel@lists.infradead.org; Wed, 10 Oct 2012 10:33:02 +0000 Received: (qmail 25923 invoked by uid 0); 10 Oct 2012 10:32:58 -0000 Received: from unknown (HELO box668.bluehost.com) (66.147.244.168) by oproxy9.bluehost.com with SMTP; 10 Oct 2012 10:32:58 -0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=makelinux.com; s=default; h=Message-Id:Date:Subject:Cc:To:From; bh=XWumBFGC7v8J7jG47DaiUhk6n8OqR1Abcflfv2e3NJs=; b=C0P6RDLk+fB9cPKmpUUHcel7gsPPN4PWPr2tkk8WHsKBFDrF3LbVPVFnL03PcEpbI8LzyfCdoioL0pLfu6F0YAcwfliZ3EngSyiOGOdFxvXjpJawZq78a+z90Xmy+niZ; Received: from [77.127.105.163] (port=59161 helo=makelinux.home) by box668.bluehost.com with esmtpa (Exim 4.76) (envelope-from ) id 1TLtaz-00046M-Ee; Wed, 10 Oct 2012 04:32:57 -0600 From: Constantine Shulyupin To: nsekhar@ti.com, gregkh@linuxfoundation.org, oneukum@suse.de Subject: [PATCH v2] USB: usb-skeleton.c: fix compilation error and restore kref_put on fail in skel_open Date: Wed, 10 Oct 2012 12:32:54 +0200 Message-Id: <1349865174-21649-1-git-send-email-const@MakeLinux.com> X-Mailer: git-send-email 1.7.9.5 X-Identified-User: {1470:box668.bluehost.com:makelinu:makelinux.net} {sentby:smtp auth 77.127.105.163 authed with poster@makelinux.net} X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: davinci-linux-open-source@linux.davincidsp.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, balbi@ti.com, Constantine Shulyupin , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Constantine Shulyupin Function skel_open increments usage count for the device with kref_get and the usage count should be decremented on the function failure. Some last changes in function skel_open and finally commit 52a7499 Revert "USB: usb-skeleton.c: fix open/disconnect race" introduced a bug in function skel_open, which this patch fixes. --- Changelog: -- Fixed accordinly feedback of Oliver Neukum oneukum@suse.de: also need to drop the lock. Signed-off-by: Constantine Shulyupin --- drivers/usb/usb-skeleton.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c index 0616f23..2025d03 100644 --- a/drivers/usb/usb-skeleton.c +++ b/drivers/usb/usb-skeleton.c @@ -113,8 +113,9 @@ static int skel_open(struct inode *inode, struct file *file) mutex_lock(&dev->io_mutex); retval = usb_autopm_get_interface(interface); - if (retval) - goto out_err; + if (retval) { + kref_put(&dev->kref, skel_delete); + } /* save our object in the file's private structure */ file->private_data = dev;