From: Markus Elfring <Markus.Elfring@web.de>
To: linux-input@vger.kernel.org, kernel-janitors@vger.kernel.org,
"Dmitry Torokhov" <dmitry.torokhov@gmail.com>,
"Oliver Graute" <oliver.graute@kococonnector.com>,
"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
"ye xingchen" <ye.xingchen@zte.com.cn>
Cc: LKML <linux-kernel@vger.kernel.org>, cocci@inria.fr
Subject: [cocci] [PATCH] Input: usbtouchscreen - Return directly after a failed kmalloc() in nexio_init()
Date: Tue, 26 Dec 2023 21:08:12 +0100 [thread overview]
Message-ID: <9365c845-baa1-44d1-add9-ec8ca4d365eb@web.de> (raw)
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.
This issue was detected by using the Coccinelle software.
Thus return directly after a call of the function “kmalloc” failed
at the beginning.
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
next reply other threads:[~2023-12-26 20:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-26 20:08 Markus Elfring [this message]
[not found] ` <ZY54UDosMHwj6D3Y@google.com>
2023-12-29 8:56 ` [cocci] Input: usbtouchscreen - Return directly after a failed kmalloc() in nexio_init() 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=9365c845-baa1-44d1-add9-ec8ca4d365eb@web.de \
--to=markus.elfring@web.de \
--cc=cocci@inria.fr \
--cc=dmitry.torokhov@gmail.com \
--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 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 read-only IMAP folder(s) and NNTP newsgroup(s).