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: 1572891 Return-Path: X-Original-To: patchwork-davinci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from bear.ext.ti.com (bear.ext.ti.com [192.94.94.41]) by patchwork2.kernel.org (Postfix) with ESMTP id D649EDFB34 for ; Wed, 10 Oct 2012 10:41:35 +0000 (UTC) Received: from dlelxv30.itg.ti.com ([172.17.2.17]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id q9AAdg9h023360; Wed, 10 Oct 2012 05:39:42 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv30.itg.ti.com (8.13.8/8.13.8) with ESMTP id q9AAdgEW030410; Wed, 10 Oct 2012 05:39:42 -0500 Received: from dlelxv23.itg.ti.com (172.17.1.198) by dfle72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.1.323.3; Wed, 10 Oct 2012 05:39:41 -0500 Received: from linux.omap.com (dlelxs01.itg.ti.com [157.170.227.31]) by dlelxv23.itg.ti.com (8.13.8/8.13.8) with ESMTP id q9AAdfpD019364; Wed, 10 Oct 2012 05:39:41 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 0CB3780627; Wed, 10 Oct 2012 05:39:41 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflp51.itg.ti.com (dflp51.itg.ti.com [128.247.22.94]) by linux.omap.com (Postfix) with ESMTP id 0EE6980626 for ; Wed, 10 Oct 2012 05:39:39 -0500 (CDT) Received: from red.ext.ti.com (red.ext.ti.com [192.94.93.37]) by dflp51.itg.ti.com (8.13.7/8.13.8) with ESMTP id q9AAdcTL020147 for ; Wed, 10 Oct 2012 05:39:38 -0500 (CDT) Received: from psmtp.com (na3sys009amx197.postini.com [74.125.149.233]) by red.ext.ti.com (8.13.7/8.13.7) with SMTP id q9AAdcJn001018 for ; Wed, 10 Oct 2012 05:39:38 -0500 Received: from oproxy9.bluehost.com ([69.89.24.6]) by na3sys009amx197.postini.com ([74.125.148.10]) with SMTP; Wed, 10 Oct 2012 01:39:38 HDT 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: , , 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-pstn-neptune: 0/0/0.00/0 X-pstn-levels: (S:32.52960/99.90000 CV:99.9000 FC:95.5390 LC:95.5390 R:95.9108 P:95.9108 M:97.0282 C:98.6951 ) X-pstn-dkim: 1 skipped:not-enabled X-pstn-settings: 2 (0.5000:0.5000) s cv gt3 gt2 gt1 r p m c X-pstn-addresses: from [82/3] CC: , , , , Constantine Shulyupin , X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: Errors-To: davinci-linux-open-source-bounces@linux.davincidsp.com 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;