diff options
| author | Manush Prajwal <manushprajwal555@gmail.com> | 2026-09-06 17:11:58 +0530 |
|---|---|---|
| committer | Uwe Kleine-König <ukleinek@kernel.org> | 2026-09-08 19:12:19 +0200 |
| commit | 17dbb6938d3ab444cd6be1c95506450595a8800d (patch) | |
| tree | a6c4646db2879f369bf9cb925a057a1388a605ea /scripts/basic/split-include.c | |
| parent | c5b29baad42b2b02389cc6a716697a8a63209930 (diff) | |
| download | linux-next-17dbb6938d3ab444cd6be1c95506450595a8800d.tar.gz linux-next-17dbb6938d3ab444cd6be1c95506450595a8800d.zip | |
pwm: lp3943: fix NULL pointer dereference for an unconfigured channel
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>
Link: https://patch.msgid.link/6a9d5187.d63de05c.175391.a17c@mx.google.com
Fixes: af66b3c0934e ("pwm: Add LP3943 PWM driver")
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
Diffstat (limited to 'scripts/basic/split-include.c')
0 files changed, 0 insertions, 0 deletions
