* [PATCH 1/2] Input: xpad - fix memory leak
@ 2010-12-01 15:04 Namhyung Kim
2010-12-01 15:04 ` [PATCH 2/2] Input: xpad - sanitize xpad_led_disconnect() Namhyung Kim
2010-12-01 17:14 ` [PATCH 1/2] Input: xpad - fix memory leak Dmitry Torokhov
0 siblings, 2 replies; 4+ messages in thread
From: Namhyung Kim @ 2010-12-01 15:04 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-input, linux-kernel
xpad->bdata was dynamically allocated but never freed. Since it is
used for xpad->bulk_out->transfer_buffer, set URB_FREE_BUFFER flag
in order to get freed when usb_free_urb() called.
Signed-off-by: Namhyung Kim <namhyung@gmail.com>
---
drivers/input/joystick/xpad.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index f9fb7fa..f885902 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -955,6 +955,7 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
usb_fill_bulk_urb(xpad->bulk_out, udev,
usb_sndbulkpipe(udev, ep_irq_in->bEndpointAddress),
xpad->bdata, XPAD_PKT_LEN, xpad_bulk_out, xpad);
+ xpad->bulk_out->transfer_flags |= URB_FREE_BUFFER;
}
return 0;
--
1.7.0.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] Input: xpad - sanitize xpad_led_disconnect()
2010-12-01 15:04 [PATCH 1/2] Input: xpad - fix memory leak Namhyung Kim
@ 2010-12-01 15:04 ` Namhyung Kim
2010-12-01 17:11 ` Dmitry Torokhov
2010-12-01 17:14 ` [PATCH 1/2] Input: xpad - fix memory leak Dmitry Torokhov
1 sibling, 1 reply; 4+ messages in thread
From: Namhyung Kim @ 2010-12-01 15:04 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-input, linux-kernel, Jan Kratochvil
IMHO kfree() here looks very confusing. xpad_led->name is an array
of char inside struct xpad_led and is not a dynamic memory itself.
But kfree() works well because it is a first member of the struct
so it points start address of the struct and frees the struct.
Change it to xpad_led for the correctness & readability and make
xpad->led NULL for the safety.
Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Cc: Jan Kratochvil <honza@jikos.cz>
---
drivers/input/joystick/xpad.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index f885902..1ca49e8 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -728,7 +728,8 @@ static void xpad_led_disconnect(struct usb_xpad *xpad)
if (xpad_led) {
led_classdev_unregister(&xpad_led->led_cdev);
- kfree(xpad_led->name);
+ kfree(xpad_led);
+ xpad->led = NULL;
}
}
#else
--
1.7.0.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] Input: xpad - sanitize xpad_led_disconnect()
2010-12-01 15:04 ` [PATCH 2/2] Input: xpad - sanitize xpad_led_disconnect() Namhyung Kim
@ 2010-12-01 17:11 ` Dmitry Torokhov
0 siblings, 0 replies; 4+ messages in thread
From: Dmitry Torokhov @ 2010-12-01 17:11 UTC (permalink / raw)
To: Namhyung Kim; +Cc: linux-input, linux-kernel, Jan Kratochvil
Hi Namhyung,
On Thu, Dec 02, 2010 at 12:04:34AM +0900, Namhyung Kim wrote:
> IMHO kfree() here looks very confusing. xpad_led->name is an array
> of char inside struct xpad_led and is not a dynamic memory itself.
> But kfree() works well because it is a first member of the struct
> so it points start address of the struct and frees the struct.
This has already been fixed in my tree, thanks.
>
> Change it to xpad_led for the correctness & readability and make
> xpad->led NULL for the safety.
>
> Signed-off-by: Namhyung Kim <namhyung@gmail.com>
> Cc: Jan Kratochvil <honza@jikos.cz>
> ---
> drivers/input/joystick/xpad.c | 3 ++-
> 1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
> index f885902..1ca49e8 100644
> --- a/drivers/input/joystick/xpad.c
> +++ b/drivers/input/joystick/xpad.c
> @@ -728,7 +728,8 @@ static void xpad_led_disconnect(struct usb_xpad *xpad)
>
> if (xpad_led) {
> led_classdev_unregister(&xpad_led->led_cdev);
> - kfree(xpad_led->name);
> + kfree(xpad_led);
> + xpad->led = NULL;
> }
> }
> #else
> --
> 1.7.0.4
>
--
Dmitry
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] Input: xpad - fix memory leak
2010-12-01 15:04 [PATCH 1/2] Input: xpad - fix memory leak Namhyung Kim
2010-12-01 15:04 ` [PATCH 2/2] Input: xpad - sanitize xpad_led_disconnect() Namhyung Kim
@ 2010-12-01 17:14 ` Dmitry Torokhov
1 sibling, 0 replies; 4+ messages in thread
From: Dmitry Torokhov @ 2010-12-01 17:14 UTC (permalink / raw)
To: Namhyung Kim; +Cc: linux-input, linux-kernel
On Thu, Dec 02, 2010 at 12:04:33AM +0900, Namhyung Kim wrote:
> xpad->bdata was dynamically allocated but never freed. Since it is
> used for xpad->bulk_out->transfer_buffer, set URB_FREE_BUFFER flag
> in order to get freed when usb_free_urb() called.
>
This is also already fixed in my tree (next branch, slated for 2.6.38).
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-12-01 17:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-01 15:04 [PATCH 1/2] Input: xpad - fix memory leak Namhyung Kim
2010-12-01 15:04 ` [PATCH 2/2] Input: xpad - sanitize xpad_led_disconnect() Namhyung Kim
2010-12-01 17:11 ` Dmitry Torokhov
2010-12-01 17:14 ` [PATCH 1/2] Input: xpad - fix memory leak Dmitry Torokhov
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).