Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753900AbbKMIbR (ORCPT ); Fri, 13 Nov 2015 03:31:17 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]:9299 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752588AbbKMIbP (ORCPT ); Fri, 13 Nov 2015 03:31:15 -0500 X-AuditID: cbfec7f4-f79c56d0000012ee-47-56459fd07d3d Subject: Re: [PATCH v5 4/7] usb: gadget: f_midi: fix leak on failed to enqueue out requests To: "Felipe F. Tonello" , linux-usb@vger.kernel.org References: <1447177929-22252-1-git-send-email-eu@felipetonello.com> <1447177929-22252-5-git-send-email-eu@felipetonello.com> Cc: linux-kernel@vger.kernel.org, Felipe Balbi , Greg Kroah-Hartman , Clemens Ladisch From: Robert Baldyga Message-id: <56459FCF.8090409@samsung.com> Date: Fri, 13 Nov 2015 09:31:11 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-version: 1.0 In-reply-to: <1447177929-22252-5-git-send-email-eu@felipetonello.com> Content-type: text/plain; charset=windows-1252 Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrMLMWRmVeSWpSXmKPExsVy+t/xK7oX5ruGGRycoGVx8H69xZITD5ks OuefZbdoXryezeLyrjlsFouWtTI7sHnc/fqQ3ePHin5mj/1z17B7HL+xncnj8ya5ANYoLpuU 1JzMstQifbsErowPO2cyFizgrPh5bDZ7A+Nu9i5GTg4JAROJ1w/3M0HYYhIX7q1n62Lk4hAS WMoo8XXeP7CEkMAzRon9yzlAbGGBWIkN5+6ygNgiAp4SJz6vY4aoqZdYt2Q7WDOzwAxGib4d 99lAEmwCOhJbvk9g7GLk4OAV0JI4sd8BJMwioCrx59wusF5RgQiJiRMaWEFsXgFBiR+T74HN 5xRwlfhydQ5YK7OAnsT9i1ogYWYBeYnNa94yT2AUmIWkYxZC1SwkVQsYmVcxiqaWJhcUJ6Xn GuoVJ+YWl+al6yXn525ihAT1lx2Mi49ZHWIU4GBU4uFNeuYSJsSaWFZcmXuIUYKDWUmEdzFI iDclsbIqtSg/vqg0J7X4EKM0B4uSOO/cXe9DhATSE0tSs1NTC1KLYLJMHJxSDYwJsgZzLSMF i+R2Tik87+n07es8aV2pw9zHA9lVX/z1bk6c1cLrIa80/a0r6wtT9wz5njUl/ELbLsueO39+ 5rV3i9hX31x4bMXkuzNeTpWxjneJvvlxcv1jl5MNpiXzM1dJ3f5stPyR8qMLtg/ZDtevCfYM Ovg8wHWz74quo72vo4olHv77mnVfiaU4I9FQi7moOBEADkKmmGYCAAA= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1396 Lines: 38 Hi Felipe, On 11/10/2015 06:52 PM, Felipe F. Tonello wrote: > This patch fixes a memory leak that occurs when an endpoint fails to enqueue > the request. If that happens the complete function will never be called, thus > never freeing the request. > > Signed-off-by: Felipe F. Tonello > --- > drivers/usb/gadget/function/f_midi.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/usb/gadget/function/f_midi.c b/drivers/usb/gadget/function/f_midi.c > index f36db2d..76ea53c 100644 > --- a/drivers/usb/gadget/function/f_midi.c > +++ b/drivers/usb/gadget/function/f_midi.c > @@ -345,6 +345,7 @@ static int f_midi_set_alt(struct usb_function *f, unsigned intf, unsigned alt) > if (err) { > ERROR(midi, "%s queue req: %d\n", > midi->out_ep->name, err); > + free_ep_req(midi->out_ep, req); > } > } > > There is one more thing I haven't noticed before. We can have situation when all requests were allocated successfully, but their allocation failed. What we get then is set_alt() returning 0, while no request is allocated, hence the function is, in fact, inactive. Best regards, Robert -- 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/