* [PATCH] USB: fix possible memory leak in pxa27x_udc
@ 2008-06-22 9:08 Marcin Slusarz
2008-06-23 22:38 ` David Brownell
0 siblings, 1 reply; 2+ messages in thread
From: Marcin Slusarz @ 2008-06-22 9:08 UTC (permalink / raw)
To: LKML; +Cc: Daniel Marjamäki, David Brownell, Greg Kroah-Hartman
Fix memory leak when _ep is null.
http://bugzilla.kernel.org/show_bug.cgi?id=10660
Noticed-by: Daniel Marjamäki <danielm77@spray.se>
Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/usb/gadget/pxa27x_udc.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c
index e02bfd4..e3a5d53 100644
--- a/drivers/usb/gadget/pxa27x_udc.c
+++ b/drivers/usb/gadget/pxa27x_udc.c
@@ -650,8 +650,11 @@ pxa_ep_alloc_request(struct usb_ep *_ep, gfp_t gfp_flags)
{
struct pxa27x_request *req;
+ if (!_ep)
+ return NULL;
+
req = kzalloc(sizeof *req, gfp_flags);
- if (!req || !_ep)
+ if (!req)
return NULL;
INIT_LIST_HEAD(&req->queue);
--
1.5.4.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] USB: fix possible memory leak in pxa27x_udc
2008-06-22 9:08 [PATCH] USB: fix possible memory leak in pxa27x_udc Marcin Slusarz
@ 2008-06-23 22:38 ` David Brownell
0 siblings, 0 replies; 2+ messages in thread
From: David Brownell @ 2008-06-23 22:38 UTC (permalink / raw)
To: Marcin Slusarz
Cc: LKML, Daniel Marjamäki, David Brownell, Greg Kroah-Hartman
On Sunday 22 June 2008, Marcin Slusarz wrote:
> --- a/drivers/usb/gadget/pxa27x_udc.c
> +++ b/drivers/usb/gadget/pxa27x_udc.c
> @@ -650,8 +650,11 @@ pxa_ep_alloc_request(struct usb_ep *_ep, gfp_t gfp_flags)
> {
> struct pxa27x_request *req;
>
> + if (!_ep)
> + return NULL;
> +
Correct enough as it goes, except that it *can't* be null by virtue
of how it's called. See <include/linux/usb/gadget.h> for:
static inline struct usb_request *usb_ep_alloc_request(struct usb_ep *ep,
gfp_t gfp_flags)
{
return ep->ops->alloc_request(ep, gfp_flags);
}
If it were null it couldn't get here. A better fix would just
remove the null check here (and possibly elsewhere).
- Dave
> req = kzalloc(sizeof *req, gfp_flags);
> - if (!req || !_ep)
> + if (!req)
> return NULL;
>
> INIT_LIST_HEAD(&req->queue);
> --
> 1.5.4.5
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-06-23 22:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-22 9:08 [PATCH] USB: fix possible memory leak in pxa27x_udc Marcin Slusarz
2008-06-23 22:38 ` David Brownell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox