linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: gadget: function: printer: Fix a memory leak for interface descriptor
@ 2020-12-09  3:00 qiang.zhang
  2020-12-09 13:45 ` Peter Chen
  0 siblings, 1 reply; 2+ messages in thread
From: qiang.zhang @ 2020-12-09  3:00 UTC (permalink / raw)
  To: balbi, gregkh; +Cc: linux-usb

From: Zqiang <qiang.zhang@windriver.com>

When printer driver be load, the printer_func_bind function be called, in
this function, the interface descriptor be allocated memory, if after that,
the error occurred, the interface descriptor memory need to be free.

Signed-off-by: Zqiang <qiang.zhang@windriver.com>
---
 drivers/usb/gadget/function/f_printer.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/gadget/function/f_printer.c b/drivers/usb/gadget/function/f_printer.c
index 64a4112068fc..2f1eb2e81d30 100644
--- a/drivers/usb/gadget/function/f_printer.c
+++ b/drivers/usb/gadget/function/f_printer.c
@@ -1162,6 +1162,7 @@ static int printer_func_bind(struct usb_configuration *c,
 		printer_req_free(dev->in_ep, req);
 	}
 
+	usb_free_all_descriptors(f);
 	return ret;
 
 }
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] usb: gadget: function: printer: Fix a memory leak for interface descriptor
  2020-12-09  3:00 [PATCH] usb: gadget: function: printer: Fix a memory leak for interface descriptor qiang.zhang
@ 2020-12-09 13:45 ` Peter Chen
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Chen @ 2020-12-09 13:45 UTC (permalink / raw)
  To: qiang.zhang@windriver.com
  Cc: balbi@kernel.org, gregkh@linuxfoundation.org,
	linux-usb@vger.kernel.org

On 20-12-09 11:00:18, qiang.zhang@windriver.com wrote:
> From: Zqiang <qiang.zhang@windriver.com>
> 
> When printer driver be load, the printer_func_bind function be called, in
		      is loaded				      is called

> this function, the interface descriptor be allocated memory, if after that,
				descriptors memory region are allocated
> the error occurred, the interface descriptor memory need to be free.
		occurs,			

Except Typo, otherwise:
Reviewed-by: Peter Chen <peter.chen@nxp.com>

Besides, it is bug-fix, you could add fixes tag, and cc stable@vger.kernel.org.

Peter

> 
> Signed-off-by: Zqiang <qiang.zhang@windriver.com>
> ---
>  drivers/usb/gadget/function/f_printer.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/usb/gadget/function/f_printer.c b/drivers/usb/gadget/function/f_printer.c
> index 64a4112068fc..2f1eb2e81d30 100644
> --- a/drivers/usb/gadget/function/f_printer.c
> +++ b/drivers/usb/gadget/function/f_printer.c
> @@ -1162,6 +1162,7 @@ static int printer_func_bind(struct usb_configuration *c,
>  		printer_req_free(dev->in_ep, req);
>  	}
>  
> +	usb_free_all_descriptors(f);
>  	return ret;
>  
>  }
> -- 
> 2.17.1
> 

-- 

Thanks,
Peter Chen

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-12-09 13:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-09  3:00 [PATCH] usb: gadget: function: printer: Fix a memory leak for interface descriptor qiang.zhang
2020-12-09 13:45 ` Peter Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).