From: Jacek Anaszewski <jacek.anaszewski@gmail.com>
To: Kangjie Lu <kjlu@umn.edu>
Cc: pakki001@umn.edu, Pavel Machek <pavel@ucw.cz>,
linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] leds: fix a missing check of return value of lp55xx_read
Date: Fri, 28 Dec 2018 17:52:27 +0100 [thread overview]
Message-ID: <333a5518-ad9d-868c-a5b6-731e10c053ea@gmail.com> (raw)
In-Reply-To: <20181226041823.73950-1-kjlu@umn.edu>
Hi Kangjie,
Thank you for the patch.
On 12/26/18 5:18 AM, Kangjie Lu wrote:
> When lp55xx_read() fails, "status" is an uninitialized variable and thus
> may contain random value; using it leads to undefined behaviors.
>
> The fix inserts a check for the return value of lp55xx_read: if it
> fails, returns with its error code.
>
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> ---
> drivers/leds/leds-lp5523.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c
> index a2e74feee2b2..fd64df5a57a5 100644
> --- a/drivers/leds/leds-lp5523.c
> +++ b/drivers/leds/leds-lp5523.c
> @@ -318,7 +318,9 @@ static int lp5523_init_program_engine(struct lp55xx_chip *chip)
>
> /* Let the programs run for couple of ms and check the engine status */
> usleep_range(3000, 6000);
> - lp55xx_read(chip, LP5523_REG_STATUS, &status);
> + ret = lp55xx_read(chip, LP5523_REG_STATUS, &status);
> + if (ret)
> + return ret;
> status &= LP5523_ENG_STATUS_MASK;
>
> if (status != LP5523_ENG_STATUS_MASK) {
>
Applied to fixes-for-4.21 branch of linux-leds.git.
--
Best regards,
Jacek Anaszewski
prev parent reply other threads:[~2018-12-28 16:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-26 4:18 [PATCH] leds: fix a missing check of return value of lp55xx_read Kangjie Lu
2018-12-28 16:52 ` Jacek Anaszewski [this message]
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=333a5518-ad9d-868c-a5b6-731e10c053ea@gmail.com \
--to=jacek.anaszewski@gmail.com \
--cc=kjlu@umn.edu \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=pakki001@umn.edu \
--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 NNTP newsgroup(s).