Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932475AbbGGQBj (ORCPT ); Tue, 7 Jul 2015 12:01:39 -0400 Received: from sender1.zohomail.com ([74.201.84.158]:24741 "EHLO sender163-mail.zoho.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932065AbbGGQBa (ORCPT ); Tue, 7 Jul 2015 12:01:30 -0400 Message-ID: <559BF79B.903@hackerion.com> Date: Tue, 07 Jul 2015 18:00:27 +0200 From: Robert Baldyga User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Dan Carpenter , Robert Baldyga CC: gregkh@linuxfoundation.org, balbi@ti.com, devel@driverdev.osuosl.org, hamohammed.sa@gmail.com, chris@rorvick.com, tapaswenipathak@gmail.com, linux-usb@vger.kernel.org, nicolas.ferre@atmel.com, hgujulan@visteon.com, mina86@mina86.com, linux-kernel@vger.kernel.org, vinc94@gmail.com, roberta.dobrescu@gmail.com, andrzej.p@samsung.com, linux-arm-kernel@lists.infradead.org, m.szyprowski@samsung.com Subject: Re: [PATCH 1/5] usb: gadget: ffs: call functionfs_unbind() if _ffs_func_bind() fails References: <1436277773-14274-1-git-send-email-r.baldyga@samsung.com> <1436277773-14274-2-git-send-email-r.baldyga@samsung.com> <20150707145345.GD4341@mwanda> In-Reply-To: <20150707145345.GD4341@mwanda> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1448 Lines: 41 On 07/07/2015 04:53 PM, Dan Carpenter wrote: > On Tue, Jul 07, 2015 at 04:02:49PM +0200, Robert Baldyga wrote: >> diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c >> index 6e7be91..966b214 100644 >> --- a/drivers/usb/gadget/function/f_fs.c >> +++ b/drivers/usb/gadget/function/f_fs.c >> @@ -2897,11 +2897,19 @@ static int ffs_func_bind(struct usb_configuration *c, >> struct usb_function *f) >> { >> struct f_fs_opts *ffs_opts = ffs_do_functionfs_bind(f, c); >> + struct ffs_function *func = ffs_func_from_usb(f); >> + int ret; >> >> if (IS_ERR(ffs_opts)) >> return PTR_ERR(ffs_opts); >> >> - return _ffs_func_bind(c, f); >> + ret = _ffs_func_bind(c, f); >> + if (ret) { >> + ffs_opts->refcnt--; > > Wait, why are we decrementing here? ffs_func_unbind() already has a > decrement so this looks like a bug to me. Add a comment if it's really > needed. Decrement is done in ffs_func_unbind() which is not called in this error path. But after all I see another problem here, because we shouldn't call functionfs_unbind() if refcnt after decrement is not equal zero. I will fix it. > >> + functionfs_unbind(func->ffs); Thanks, Robert Baldyga -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/