From: Markus Elfring <Markus.Elfring@web.de> To: linux-input@vger.kernel.org, kernel-janitors@vger.kernel.org, Dmitry Torokhov <dmitry.torokhov@gmail.com>, Henrik Rydberg <rydberg@bitmath.org> Cc: LKML <linux-kernel@vger.kernel.org>, cocci@inria.fr Subject: [PATCH] Input: MT - Return directly after a failed kzalloc() in input_mt_init_slots() Date: Tue, 26 Dec 2023 20:43:37 +0100 [thread overview] Message-ID: <5088a905-4f29-41d3-a96e-5b66aad551f1@web.de> (raw) From: Markus Elfring <elfring@users.sourceforge.net> Date: Tue, 26 Dec 2023 20:36:09 +0100 The kfree() function was called in one case by the input_mt_init_slots() 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 “kzalloc” failed at the beginning. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> --- drivers/input/input-mt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/input-mt.c b/drivers/input/input-mt.c index 14b53dac1253..24064447d600 100644 --- a/drivers/input/input-mt.c +++ b/drivers/input/input-mt.c @@ -49,7 +49,7 @@ int input_mt_init_slots(struct input_dev *dev, unsigned int num_slots, mt = kzalloc(struct_size(mt, slots, num_slots), GFP_KERNEL); if (!mt) - goto err_mem; + return -ENOMEM; mt->num_slots = num_slots; mt->flags = flags; -- 2.43.0
WARNING: multiple messages have this Message-ID (diff)
From: Markus Elfring <Markus.Elfring@web.de> To: linux-input@vger.kernel.org, kernel-janitors@vger.kernel.org, Dmitry Torokhov <dmitry.torokhov@gmail.com>, Henrik Rydberg <rydberg@bitmath.org> Cc: LKML <linux-kernel@vger.kernel.org>, cocci@inria.fr Subject: [cocci] [PATCH] Input: MT - Return directly after a failed kzalloc() in input_mt_init_slots() Date: Tue, 26 Dec 2023 20:43:37 +0100 [thread overview] Message-ID: <5088a905-4f29-41d3-a96e-5b66aad551f1@web.de> (raw) From: Markus Elfring <elfring@users.sourceforge.net> Date: Tue, 26 Dec 2023 20:36:09 +0100 The kfree() function was called in one case by the input_mt_init_slots() 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 “kzalloc” failed at the beginning. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> --- drivers/input/input-mt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/input-mt.c b/drivers/input/input-mt.c index 14b53dac1253..24064447d600 100644 --- a/drivers/input/input-mt.c +++ b/drivers/input/input-mt.c @@ -49,7 +49,7 @@ int input_mt_init_slots(struct input_dev *dev, unsigned int num_slots, mt = kzalloc(struct_size(mt, slots, num_slots), GFP_KERNEL); if (!mt) - goto err_mem; + return -ENOMEM; mt->num_slots = num_slots; mt->flags = flags; -- 2.43.0
next reply other threads:[~2023-12-26 19:43 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-12-26 19:43 Markus Elfring [this message] 2023-12-26 19:43 ` [cocci] [PATCH] Input: MT - Return directly after a failed kzalloc() in input_mt_init_slots() Markus Elfring 2023-12-29 7:43 ` Dmitry Torokhov 2023-12-29 9:00 ` [cocci] " Markus Elfring 2023-12-29 9:00 ` 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=5088a905-4f29-41d3-a96e-5b66aad551f1@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=rydberg@bitmath.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: linkBe 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.