* [PATCH] drm/bridge: it6505: Fix potential NULL dereference
@ 2024-06-08 14:21 Dan Carpenter
2024-06-09 19:33 ` Dmitry Baryshkov
2024-06-09 19:38 ` Dmitry Baryshkov
0 siblings, 2 replies; 4+ messages in thread
From: Dan Carpenter @ 2024-06-08 14:21 UTC (permalink / raw)
To: Allen Chen
Cc: Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
Jonas Karlman, Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Daniel Vetter, Hermes Wu,
AngeloGioacchino Del Regno, dri-devel, linux-kernel,
kernel-janitors
Smatch complains correctly that the NULL checking isn't consistent:
drivers/gpu/drm/bridge/ite-it6505.c:2583 it6505_poweron()
error: we previously assumed 'pdata->pwr18' could be null
(see line 2569)
Add a NULL check to prevent a NULL dereference on the error path.
Fixes: b5c84a9edcd4 ("drm/bridge: add it6505 driver")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
drivers/gpu/drm/bridge/ite-it6505.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c
index 3f68c82888c2..4f01fadaec0f 100644
--- a/drivers/gpu/drm/bridge/ite-it6505.c
+++ b/drivers/gpu/drm/bridge/ite-it6505.c
@@ -2580,7 +2580,8 @@ static int it6505_poweron(struct it6505 *it6505)
usleep_range(1000, 2000);
err = regulator_enable(pdata->ovdd);
if (err) {
- regulator_disable(pdata->pwr18);
+ if (pdata->pwr18)
+ regulator_disable(pdata->pwr18);
return err;
}
}
--
2.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] drm/bridge: it6505: Fix potential NULL dereference
2024-06-08 14:21 [PATCH] drm/bridge: it6505: Fix potential NULL dereference Dan Carpenter
@ 2024-06-09 19:33 ` Dmitry Baryshkov
2024-06-09 19:38 ` Dmitry Baryshkov
1 sibling, 0 replies; 4+ messages in thread
From: Dmitry Baryshkov @ 2024-06-09 19:33 UTC (permalink / raw)
To: Dan Carpenter
Cc: Allen Chen, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
David Airlie, Daniel Vetter, Hermes Wu,
AngeloGioacchino Del Regno, dri-devel, linux-kernel,
kernel-janitors
On Sat, Jun 08, 2024 at 05:21:08PM +0300, Dan Carpenter wrote:
> Smatch complains correctly that the NULL checking isn't consistent:
>
> drivers/gpu/drm/bridge/ite-it6505.c:2583 it6505_poweron()
> error: we previously assumed 'pdata->pwr18' could be null
> (see line 2569)
>
> Add a NULL check to prevent a NULL dereference on the error path.
>
> Fixes: b5c84a9edcd4 ("drm/bridge: add it6505 driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
> drivers/gpu/drm/bridge/ite-it6505.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] drm/bridge: it6505: Fix potential NULL dereference
2024-06-08 14:21 [PATCH] drm/bridge: it6505: Fix potential NULL dereference Dan Carpenter
2024-06-09 19:33 ` Dmitry Baryshkov
@ 2024-06-09 19:38 ` Dmitry Baryshkov
2024-06-09 20:59 ` Dan Carpenter
1 sibling, 1 reply; 4+ messages in thread
From: Dmitry Baryshkov @ 2024-06-09 19:38 UTC (permalink / raw)
To: Dan Carpenter
Cc: Allen Chen, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
David Airlie, Daniel Vetter, Hermes Wu,
AngeloGioacchino Del Regno, dri-devel, linux-kernel,
kernel-janitors
On Sat, Jun 08, 2024 at 05:21:08PM +0300, Dan Carpenter wrote:
> Smatch complains correctly that the NULL checking isn't consistent:
>
> drivers/gpu/drm/bridge/ite-it6505.c:2583 it6505_poweron()
> error: we previously assumed 'pdata->pwr18' could be null
> (see line 2569)
>
> Add a NULL check to prevent a NULL dereference on the error path.
>
> Fixes: b5c84a9edcd4 ("drm/bridge: add it6505 driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
> drivers/gpu/drm/bridge/ite-it6505.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c
> index 3f68c82888c2..4f01fadaec0f 100644
> --- a/drivers/gpu/drm/bridge/ite-it6505.c
> +++ b/drivers/gpu/drm/bridge/ite-it6505.c
> @@ -2580,7 +2580,8 @@ static int it6505_poweron(struct it6505 *it6505)
> usleep_range(1000, 2000);
> err = regulator_enable(pdata->ovdd);
> if (err) {
> - regulator_disable(pdata->pwr18);
> + if (pdata->pwr18)
> + regulator_disable(pdata->pwr18);
Wait... I wat too quick to R-B it. The driver uses devm_regulator_get(),
which always returns non-NULL result. So all `if (pdata->pwr18)` and
`if (pdata->ovdd)` checks in the driver are useless. Could you please
send a patch, removing them?
> return err;
> }
> }
> --
> 2.43.0
>
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] drm/bridge: it6505: Fix potential NULL dereference
2024-06-09 19:38 ` Dmitry Baryshkov
@ 2024-06-09 20:59 ` Dan Carpenter
0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2024-06-09 20:59 UTC (permalink / raw)
To: Dmitry Baryshkov
Cc: Allen Chen, Andrzej Hajda, Neil Armstrong, Robert Foss,
Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
David Airlie, Daniel Vetter, Hermes Wu,
AngeloGioacchino Del Regno, dri-devel, linux-kernel,
kernel-janitors
On Sun, Jun 09, 2024 at 10:38:39PM +0300, Dmitry Baryshkov wrote:
> On Sat, Jun 08, 2024 at 05:21:08PM +0300, Dan Carpenter wrote:
> > Smatch complains correctly that the NULL checking isn't consistent:
> >
> > drivers/gpu/drm/bridge/ite-it6505.c:2583 it6505_poweron()
> > error: we previously assumed 'pdata->pwr18' could be null
> > (see line 2569)
> >
> > Add a NULL check to prevent a NULL dereference on the error path.
> >
> > Fixes: b5c84a9edcd4 ("drm/bridge: add it6505 driver")
> > Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> > ---
> > drivers/gpu/drm/bridge/ite-it6505.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c
> > index 3f68c82888c2..4f01fadaec0f 100644
> > --- a/drivers/gpu/drm/bridge/ite-it6505.c
> > +++ b/drivers/gpu/drm/bridge/ite-it6505.c
> > @@ -2580,7 +2580,8 @@ static int it6505_poweron(struct it6505 *it6505)
> > usleep_range(1000, 2000);
> > err = regulator_enable(pdata->ovdd);
> > if (err) {
> > - regulator_disable(pdata->pwr18);
> > + if (pdata->pwr18)
> > + regulator_disable(pdata->pwr18);
>
> Wait... I wat too quick to R-B it. The driver uses devm_regulator_get(),
> which always returns non-NULL result. So all `if (pdata->pwr18)` and
> `if (pdata->ovdd)` checks in the driver are useless. Could you please
> send a patch, removing them?
>
Sure. Will do.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-06-09 20:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-08 14:21 [PATCH] drm/bridge: it6505: Fix potential NULL dereference Dan Carpenter
2024-06-09 19:33 ` Dmitry Baryshkov
2024-06-09 19:38 ` Dmitry Baryshkov
2024-06-09 20:59 ` Dan Carpenter
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®