From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Markus Elfring <Markus.Elfring@web.de>
Cc: linux-input@vger.kernel.org, kernel-janitors@vger.kernel.org,
"Oliver Graute" <oliver.graute@kococonnector.com>,
"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
"ye xingchen" <ye.xingchen@zte.com.cn>,
LKML <linux-kernel@vger.kernel.org>,
cocci@inria.fr
Subject: Re: [PATCH] Input: usbtouchscreen - Return directly after a failed kmalloc() in nexio_init()
Date: Thu, 28 Dec 2023 23:42:08 -0800 [thread overview]
Message-ID: <ZY54UDosMHwj6D3Y@google.com> (raw)
In-Reply-To: <9365c845-baa1-44d1-add9-ec8ca4d365eb@web.de>
On Tue, Dec 26, 2023 at 09:08:12PM +0100, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 26 Dec 2023 21:00:25 +0100
>
> The kfree() function was called in one case by
> the nexio_init() function during error handling
> even if the passed variable contained a null pointer.
Which is perfectly valid thing to do, like free(), kfree() accepts NULL
argument.
> This issue was detected by using the Coccinelle software.
This tells me precisely nothing.
>
> Thus return directly after a call of the function “kmalloc” failed
> at the beginning.
This is simply a matter of preference, the original author preferred
that style, I see no objective reason to change it.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/input/touchscreen/usbtouchscreen.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/input/touchscreen/usbtouchscreen.c b/drivers/input/touchscreen/usbtouchscreen.c
> index 60354ebc7242..1873c7918a78 100644
> --- a/drivers/input/touchscreen/usbtouchscreen.c
> +++ b/drivers/input/touchscreen/usbtouchscreen.c
> @@ -977,7 +977,7 @@ static int nexio_init(struct usbtouch_usb *usbtouch)
>
> buf = kmalloc(NEXIO_BUFSIZE, GFP_NOIO);
> if (!buf)
> - goto out_buf;
> + return ret;
>
> /* two empty reads */
> for (i = 0; i < 2; i++) {
> --
> 2.43.0
>
Thanks.
--
Dmitry
next prev parent reply other threads:[~2023-12-29 7:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-26 20:08 [cocci] [PATCH] Input: usbtouchscreen - Return directly after a failed kmalloc() in nexio_init() Markus Elfring
2023-12-26 20:08 ` Markus Elfring
2023-12-29 7:42 ` Dmitry Torokhov [this message]
2023-12-29 8:56 ` [cocci] " Markus Elfring
2023-12-29 8:56 ` Markus Elfring
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=ZY54UDosMHwj6D3Y@google.com \
--to=dmitry.torokhov@gmail.com \
--cc=Markus.Elfring@web.de \
--cc=cocci@inria.fr \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oliver.graute@kococonnector.com \
--cc=u.kleine-koenig@pengutronix.de \
--cc=ye.xingchen@zte.com.cn \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.