Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757634AbbGGOFX (ORCPT ); Tue, 7 Jul 2015 10:05:23 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:59867 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757449AbbGGOEs (ORCPT ); Tue, 7 Jul 2015 10:04:48 -0400 X-AuditID: cbfee61b-f79416d0000014c0-1b-559bdc7e1ef7 From: Robert Baldyga To: gregkh@linuxfoundation.org, balbi@ti.com Cc: nicolas.ferre@atmel.com, vinc94@gmail.com, hamohammed.sa@gmail.com, tapaswenipathak@gmail.com, roberta.dobrescu@gmail.com, hgujulan@visteon.com, chris@rorvick.com, mina86@mina86.com, andrzej.p@samsung.com, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, m.szyprowski@samsung.com, Robert Baldyga Subject: [PATCH 1/5] usb: gadget: ffs: call functionfs_unbind() if _ffs_func_bind() fails Date: Tue, 07 Jul 2015 16:02:49 +0200 Message-id: <1436277773-14274-2-git-send-email-r.baldyga@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1436277773-14274-1-git-send-email-r.baldyga@samsung.com> References: <1436277773-14274-1-git-send-email-r.baldyga@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrALMWRmVeSWpSXmKPExsVy+t9jQd26O7NDDVoPylrMetnOYnHwfr3F zrn7WC32nPnFbtG8eD2bxZ1pk5gsHs2czGKx6fE1VovLu+awWSxa1spssfbIXXaLBcdbWC2+ XW5mt3hweCe7RcuJR2wWfac2MVusuf+RyUHQY8GvrSwe9/YdZvHYOesuu8f+uWvYPTYvqfdY 9+cVk8fu06wefVtWMXocv7GdyePzJjmPHdsvsgdwR3HZpKTmZJalFunbJXBlXD6wjq1gC0fF lwN72BsYG9i7GDk5JARMJN48fcUMYYtJXLi3nq2LkYtDSGA6o8Tc4y9YIJyfjBJr9p8G62AT 0JHY8n0CI4gtAmSv+7sDrINZYDqzxKsN04A6ODiEBaIlOp5ngNSwCKhK7HvQzAZi8wq4Stz4 cZMRYpucxMljk1lBbE4BN4m5U2czgrQKAdWs3Ow4gZF3ASPDKkbR1ILkguKk9FwjveLE3OLS vHS95PzcTYzgcH8mvYNxVYPFIUYBDkYlHt6bErNDhVgTy4orcw8xSnAwK4nwvjkJFOJNSays Si3Kjy8qzUktPsQozcGiJM57Mt8nVEggPbEkNTs1tSC1CCbLxMEp1cBYxZbqOfHX+q55W/U+ nOm7Vr5jxRFl9h8vZl2Wc/7F8uOQGstVnYOZc/+urJ/cGl+uEKy4nOn8cu3u2uQbdZVXn97i mWPaIdURzXLw+qzP3E96pTsXVD7e2ndc0+d++aZfretvNBw1LliR/9qLr5jNx+fINKsCR86n /M8r2Xe73FXR+ZLAek9SiaU4I9FQi7moOBEAvFWUDnMCAAA= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1284 Lines: 42 Function ffs_do_functionfs_bind() calls functionfs_bind() which allocates usb request and increments refcounts. These things needs to be cleaned up by if further steps of initialization fail by calling functionfs_unbind(). Signed-off-by: Robert Baldyga --- drivers/usb/gadget/function/f_fs.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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--; + functionfs_unbind(func->ffs); + } + + return ret; } -- 1.9.1 -- 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/