Fix cases where smatch reports a use of an uninitialized variable, and
one where the variable is initialized but contains wrong value.
Tomi
Signed-off-by: Tomi Valkeinen <[email protected]>
---
Changes in v2:
- Added two more fixes
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Tomi Valkeinen (4):
drm/drm_file: fix use of uninitialized variable
drm/framebuffer: Fix use of uninitialized variable
drm/bridge: cdns-mhdp8546: Fix use of uninitialized variable
drm/bridge: tc358767: Fix return value on error case
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-hdcp.c | 3 ++-
drivers/gpu/drm/bridge/tc358767.c | 2 +-
drivers/gpu/drm/drm_file.c | 2 +-
drivers/gpu/drm/drm_framebuffer.c | 2 +-
4 files changed, 5 insertions(+), 4 deletions(-)
---
base-commit: 9d7c8c066916f231ca0ed4e4fce6c4b58ca3e451
change-id: 20230804-uninit-fixes-188f92d60ac3
Best regards,
--
Tomi Valkeinen <[email protected]>
smatch reports:
drivers/gpu/drm/drm_framebuffer.c:654 drm_mode_getfb2_ioctl() error: uninitialized symbol 'ret'.
'ret' is possibly not set when there are no errors, causing the error
above. I can't say if that ever happens in real-life, but in any case I
think it is good to initialize 'ret' to 0.
Reviewed-by: Laurent Pinchart <[email protected]>
Signed-off-by: Tomi Valkeinen <[email protected]>
---
drivers/gpu/drm/drm_framebuffer.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c
index 09e289fca5c3..3cc0ffc28e86 100644
--- a/drivers/gpu/drm/drm_framebuffer.c
+++ b/drivers/gpu/drm/drm_framebuffer.c
@@ -583,7 +583,7 @@ int drm_mode_getfb2_ioctl(struct drm_device *dev,
struct drm_mode_fb_cmd2 *r = data;
struct drm_framebuffer *fb;
unsigned int i;
- int ret;
+ int ret = 0;
if (!drm_core_check_feature(dev, DRIVER_MODESET))
return -EINVAL;
--
2.34.1
If the hpd_pin is invalid, the driver returns 'ret'. But 'ret' contains
0, instead of an error value.
Return -EINVAL instead.
Fixes: f25ee5017e4f ("drm/bridge: tc358767: add IRQ and HPD support")
Signed-off-by: Tomi Valkeinen <[email protected]>
---
drivers/gpu/drm/bridge/tc358767.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c
index ef2e373606ba..615cc8f950d7 100644
--- a/drivers/gpu/drm/bridge/tc358767.c
+++ b/drivers/gpu/drm/bridge/tc358767.c
@@ -2273,7 +2273,7 @@ static int tc_probe(struct i2c_client *client)
} else {
if (tc->hpd_pin < 0 || tc->hpd_pin > 1) {
dev_err(dev, "failed to parse HPD number\n");
- return ret;
+ return -EINVAL;
}
}
--
2.34.1
Hi all,
On 03/11/2023 15:14, Tomi Valkeinen wrote:
> Fix cases where smatch reports a use of an uninitialized variable, and
> one where the variable is initialized but contains wrong value.
>
> Tomi
>
> Signed-off-by: Tomi Valkeinen <[email protected]>
> ---
> Changes in v2:
> - Added two more fixes
> - Link to v1: https://lore.kernel.org/r/[email protected]
>
> ---
> Tomi Valkeinen (4):
> drm/drm_file: fix use of uninitialized variable
> drm/framebuffer: Fix use of uninitialized variable
> drm/bridge: cdns-mhdp8546: Fix use of uninitialized variable
> drm/bridge: tc358767: Fix return value on error case
>
> drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-hdcp.c | 3 ++-
> drivers/gpu/drm/bridge/tc358767.c | 2 +-
> drivers/gpu/drm/drm_file.c | 2 +-
> drivers/gpu/drm/drm_framebuffer.c | 2 +-
> 4 files changed, 5 insertions(+), 4 deletions(-)
> ---
> base-commit: 9d7c8c066916f231ca0ed4e4fce6c4b58ca3e451
> change-id: 20230804-uninit-fixes-188f92d60ac3
>
> Best regards,
Ping on this (or I'll forget the series...).
Tomi
On Wed, Dec 06, 2023 at 02:50:57PM +0200, Tomi Valkeinen wrote:
> Hi all,
>
> On 03/11/2023 15:14, Tomi Valkeinen wrote:
> > Fix cases where smatch reports a use of an uninitialized variable, and
> > one where the variable is initialized but contains wrong value.
> >
> > Tomi
> >
> > Signed-off-by: Tomi Valkeinen <[email protected]>
> > ---
> > Changes in v2:
> > - Added two more fixes
> > - Link to v1: https://lore.kernel.org/r/[email protected]
> >
> > ---
> > Tomi Valkeinen (4):
> > drm/drm_file: fix use of uninitialized variable
> > drm/framebuffer: Fix use of uninitialized variable
> > drm/bridge: cdns-mhdp8546: Fix use of uninitialized variable
> > drm/bridge: tc358767: Fix return value on error case
> >
> > drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-hdcp.c | 3 ++-
> > drivers/gpu/drm/bridge/tc358767.c | 2 +-
> > drivers/gpu/drm/drm_file.c | 2 +-
> > drivers/gpu/drm/drm_framebuffer.c | 2 +-
> > 4 files changed, 5 insertions(+), 4 deletions(-)
> > ---
> > base-commit: 9d7c8c066916f231ca0ed4e4fce6c4b58ca3e451
> > change-id: 20230804-uninit-fixes-188f92d60ac3
> >
> > Best regards,
>
> Ping on this (or I'll forget the series...).
Acked-by: Maxime Ripard <[email protected]>
Maxime