From: Pavel Machek <pavel@ucw.cz>
To: Shuah Khan <skhan@linuxfoundation.org>
Cc: patches@opensource.cirrus.com, linux-leds@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] leds: leds-wm831x-status: init chip_pdata before access
Date: Tue, 22 Nov 2022 22:05:09 +0100 [thread overview]
Message-ID: <Y305hfVdhs9zwOi/@duo.ucw.cz> (raw)
In-Reply-To: <20221122204837.11611-1-skhan@linuxfoundation.org>
[-- Attachment #1: Type: text/plain, Size: 1180 bytes --]
Hi!
> wm831x_status_probe() accesses status from chip_pdata before
> initializing it. Fix it.
>
> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Does it? ARRAY_SIZE() will be compile-time constant, no?
What is the bug? Did you test the code?
Best regards,
Pavel
> +++ b/drivers/leds/leds-wm831x-status.c
> @@ -212,7 +212,7 @@ static int wm831x_status_probe(struct platform_device *pdev)
> struct wm831x_status_pdata pdata;
> struct wm831x_status *drvdata;
> struct resource *res;
> - int id = pdev->id % ARRAY_SIZE(chip_pdata->status);
> + int id;
> int ret;
>
> res = platform_get_resource(pdev, IORESOURCE_REG, 0);
> @@ -229,9 +229,10 @@ static int wm831x_status_probe(struct platform_device *pdev)
> drvdata->wm831x = wm831x;
> drvdata->reg = res->start;
>
> - if (dev_get_platdata(wm831x->dev))
> + if (dev_get_platdata(wm831x->dev)) {
> chip_pdata = dev_get_platdata(wm831x->dev);
> - else
> + id = pdev->id % ARRAY_SIZE(chip_pdata->status);
> + } else
> chip_pdata = NULL;
>
> memset(&pdata, 0, sizeof(pdata));
--
People of Russia, stop Putin before his war on Ukraine escalates.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
next prev parent reply other threads:[~2022-11-22 21:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-22 20:48 Shuah Khan
2022-11-22 21:05 ` Pavel Machek [this message]
2022-11-22 22:39 ` Shuah Khan
2022-11-22 23:08 ` Pavel Machek
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=Y305hfVdhs9zwOi/@duo.ucw.cz \
--to=pavel@ucw.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=patches@opensource.cirrus.com \
--cc=skhan@linuxfoundation.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: 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
all inboxes | Powered by JetHome®