From: Greg KH <gregkh@linuxfoundation.org>
To: Ma Ke <make24@iscas.ac.cn>
Cc: dmitry.torokhov@gmail.com, bentiss@kernel.org, jeff@labundy.com,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
akpm@linux-foundation.org, stable@vger.kernel.org
Subject: Re: [PATCH] Input: fix error handling in input_register_device()
Date: Thu, 13 Mar 2025 11:01:05 +0100 [thread overview]
Message-ID: <2025031350-nutty-gatherer-3e69@gregkh> (raw)
In-Reply-To: <20250313083803.307646-1-make24@iscas.ac.cn>
On Thu, Mar 13, 2025 at 04:38:03PM +0800, Ma Ke wrote:
> Once device_add() failed, we should call put_device() to decrement
> reference count for cleanup. Or it could cause memory leak.
>
> As comment of device_add() says, 'if device_add() succeeds, you should
> call device_del() when you want to get rid of it. If device_add() has
> not succeeded, use only put_device() to drop the reference count'.
>
> Found by code review.
>
> Cc: stable@vger.kernel.org
> Fixes: 0cd587735205 ("Input: preallocate memory to hold event values")
> Signed-off-by: Ma Ke <make24@iscas.ac.cn>
> ---
> drivers/input/input.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/input/input.c b/drivers/input/input.c
> index c9e3ac64bcd0..2e70f346dadc 100644
> --- a/drivers/input/input.c
> +++ b/drivers/input/input.c
> @@ -2424,6 +2424,7 @@ int input_register_device(struct input_dev *dev)
> err_device_del:
> device_del(&dev->dev);
> err_devres_free:
> + put_device(&dev->dev);
Did you test this? This is not going to work properly for all places
that call this label.
While these types of fixes are nice to have, PLEASE TEST THEM!!!!
Stop doing these and verify, by actual tests, that they do what you
think they are doing before sending any more of them. As it is, this
stream of "fixes" is just too full of bugs for any of us to trust them
at all.
thanks,
greg k-h
next prev parent reply other threads:[~2025-03-13 10:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-13 8:38 [PATCH] Input: fix error handling in input_register_device() Ma Ke
2025-03-13 10:01 ` Greg KH [this message]
-- strict thread matches above, loose matches on Subject: below --
2025-01-05 9:24 [PATCH] Input: Fix " Ma Ke
2025-01-06 6:56 ` 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=2025031350-nutty-gatherer-3e69@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=akpm@linux-foundation.org \
--cc=bentiss@kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=jeff@labundy.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=make24@iscas.ac.cn \
--cc=stable@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).