From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Namhyung Kim <namhyung@gmail.com>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
Jan Kratochvil <honza@jikos.cz>
Subject: Re: [PATCH 2/2] Input: xpad - sanitize xpad_led_disconnect()
Date: Wed, 1 Dec 2010 09:11:14 -0800 [thread overview]
Message-ID: <20101201171114.GA11196@core.coreip.homeip.net> (raw)
In-Reply-To: <1291215874-5625-2-git-send-email-namhyung@gmail.com>
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
next prev parent reply other threads:[~2010-12-01 17:11 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2010-12-01 17:14 ` [PATCH 1/2] Input: xpad - fix memory leak Dmitry Torokhov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20101201171114.GA11196@core.coreip.homeip.net \
--to=dmitry.torokhov@gmail.com \
--cc=honza@jikos.cz \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=namhyung@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®