Linux-LEDs Archive mirror
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: linux-leds@vger.kernel.org, kernel-janitors@vger.kernel.org,
	Lee Jones <lee@kernel.org>, Pavel Machek <pavel@ucw.cz>
Cc: LKML <linux-kernel@vger.kernel.org>, cocci@inria.fr
Subject: [PATCH] leds: trigger: oneshot: One function call less in pattern_init() after error detection
Date: Tue, 26 Dec 2023 22:08:44 +0100	[thread overview]
Message-ID: <c73761c5-7150-4f20-9b3e-1da680400250@web.de> (raw)

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 26 Dec 2023 22:02:08 +0100

The kfree() function was called in one case by
the pattern_init() function during error handling
even if the passed variable contained a null pointer.
This issue was detected by using the Coccinelle software.

Thus use another label.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/leds/trigger/ledtrig-oneshot.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/leds/trigger/ledtrig-oneshot.c b/drivers/leds/trigger/ledtrig-oneshot.c
index bee3bd452abf..31061ec0afe6 100644
--- a/drivers/leds/trigger/ledtrig-oneshot.c
+++ b/drivers/leds/trigger/ledtrig-oneshot.c
@@ -134,7 +134,7 @@ static void pattern_init(struct led_classdev *led_cdev)

 	pattern = led_get_default_pattern(led_cdev, &size);
 	if (!pattern)
-		goto out_default;
+		goto out_settings;

 	if (size != 2) {
 		dev_warn(led_cdev->dev,
@@ -151,6 +151,7 @@ static void pattern_init(struct led_classdev *led_cdev)

 out_default:
 	kfree(pattern);
+out_settings:
 	led_cdev->blink_delay_on = DEFAULT_DELAY;
 	led_cdev->blink_delay_off = DEFAULT_DELAY;
 }
--
2.43.0


             reply	other threads:[~2023-12-26 21:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-26 21:08 Markus Elfring [this message]
2024-01-11 10:41 ` [PATCH] leds: trigger: oneshot: One function call less in pattern_init() after error detection Lee Jones
2024-01-11 12:03   ` Markus Elfring
2024-01-11 13:05     ` Lee Jones

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=c73761c5-7150-4f20-9b3e-1da680400250@web.de \
    --to=markus.elfring@web.de \
    --cc=cocci@inria.fr \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=lee@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=pavel@ucw.cz \
    /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).