Linux Framebuffer Layer development
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@kernel.org>
To: Lee Jones <lee@kernel.org>,
	Daniel Thompson <daniel.thompson@linaro.org>,
	Jingoo Han <jingoohan1@gmail.com>, Helge Deller <deller@gmx.de>,
	Artur Weber <aweber.kernel@gmail.com>
Cc: "Arnd Bergmann" <arnd@arndb.de>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Benjamin Mugnier" <benjamin.mugnier@foss.st.com>,
	"Krzysztof Kozlowski" <krzysztof.kozlowski@linaro.org>,
	dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH] backlight: lp855x: fix unintialized function return
Date: Fri, 11 Aug 2023 15:15:53 +0200	[thread overview]
Message-ID: <20230811131600.2380519-1-arnd@kernel.org> (raw)

From: Arnd Bergmann <arnd@arndb.de>

The function now returns an error code in some cases, but fails to initialize
it in others:

drivers/video/backlight/lp855x_bl.c:252:11: error: variable 'ret' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
        else if (lp->mode == REGISTER_BASED)
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/video/backlight/lp855x_bl.c:256:9: note: uninitialized use occurs here
        return ret;
               ^~~
drivers/video/backlight/lp855x_bl.c:252:7: note: remove the 'if' if its condition is always true
        else if (lp->mode == REGISTER_BASED)
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Since this case should not actually happen, return the -EINVAL code.

Fixes: 5145531be5fba ("backlight: lp855x: Catch errors when changing brightness")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/video/backlight/lp855x_bl.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/video/backlight/lp855x_bl.c b/drivers/video/backlight/lp855x_bl.c
index 61a7f45bfad84..ea4fa69e49a70 100644
--- a/drivers/video/backlight/lp855x_bl.c
+++ b/drivers/video/backlight/lp855x_bl.c
@@ -252,6 +252,8 @@ static int lp855x_bl_update_status(struct backlight_device *bl)
 	else if (lp->mode == REGISTER_BASED)
 		ret = lp855x_write_byte(lp, lp->cfg->reg_brightness,
 					(u8)brightness);
+	else
+		ret = -EINVAL;
 
 	return ret;
 }
-- 
2.39.2


             reply	other threads:[~2023-08-11 13:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-11 13:15 Arnd Bergmann [this message]
2023-08-14  8:41 ` [PATCH] backlight: lp855x: fix unintialized function return Daniel Thompson

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=20230811131600.2380519-1-arnd@kernel.org \
    --to=arnd@kernel.org \
    --cc=arnd@arndb.de \
    --cc=aweber.kernel@gmail.com \
    --cc=benjamin.mugnier@foss.st.com \
    --cc=daniel.thompson@linaro.org \
    --cc=deller@gmx.de \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jingoohan1@gmail.com \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=lee@kernel.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=u.kleine-koenig@pengutronix.de \
    /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