From: "Uwe Kleine-König" <ukleinek@kernel.org>
To: Manush Prajwal <manushprajwal555@gmail.com>
Cc: linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] pwm: lp3943: fix NULL pointer dereference for an unconfigured channel
Date: Tue, 8 Sep 2026 19:13:53 +0200 [thread overview]
Message-ID: <aqBBapT-KcJDDDGB@monoceros> (raw)
In-Reply-To: <6a9d5187.d63de05c.175391.a17c@mx.google.com>
[-- Attachment #1: Type: text/plain, Size: 1736 bytes --]
On Sun, Sep 06, 2026 at 05:11:58PM +0530, Manush Prajwal wrote:
> lp3943_pwm_probe() unconditionally registers a pwmchip with
> LP3943_NUM_PWMS(2) hwpwm channels, but lp3943_pwm_parse_dt() only
> populates pdata->pwms[i] for the channels whose ti,pwm0/ti,pwm1
> property is actually present in the devicetree (the binding
> explicitly allows each PWM generator to drive zero or more outputs,
> and lp3943_pwm_parse_dt() only fails outright with -ENODATA if
> *neither* property is present). A devicetree that configures only one
> of the two channels leaves pdata->pwms[] NULL for the other.
>
> lp3943_pwm_request_map() dereferences pdata->pwms[hwpwm] with no NULL
> check:
>
> pwm_map->output = pdata->pwms[hwpwm]->output;
> pwm_map->num_outputs = pdata->pwms[hwpwm]->num_outputs;
>
> so requesting the unconfigured channel (e.g. exporting it from
> sysfs) crashes with a NULL pointer dereference instead of failing
> cleanly.
>
> Return -ENODEV from lp3943_pwm_request_map() when the channel was
> never configured, before the pointer is dereferenced. The caller,
> lp3943_pwm_request(), already propagates an ERR_PTR return correctly
> (it does so today for the existing -EBUSY case).
>
> Reported-by: Sashiko AI review <sashiko-bot@kernel.org>
> Closes: https://sashiko.dev/#/patchset/6a9d4c6b.79b5ea6e.147aa1.5883@mx.google.com?part=1
> Signed-off-by: Manush Prajwal <manushprajwal555@gmail.com>
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/ukleinek/linux.git pwm/for-next
adding a Fixes trailer for af66b3c0934e ("pwm: Add LP3943 PWM driver").
I havn't made up my mind yet if I send a fixes PR before 7.3. If I do I
will likely include this patch.
Best regards
Uwe
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
prev parent reply other threads:[~2026-09-08 17:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-06 11:41 [PATCH] pwm: lp3943: fix NULL pointer dereference for an unconfigured channel Manush Prajwal
2026-09-08 17:13 ` Uwe Kleine-König [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=aqBBapT-KcJDDDGB@monoceros \
--to=ukleinek@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=manushprajwal555@gmail.com \
/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 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.