drm: Fix errors about uninitialized variables
Subsystems (2)
cover drm: Fix errors about uninitialized variables
Fix two cases where smatch reports a use of an uninitialized variable.
Tomi
---
Tomi Valkeinen (2):
drm/drm_file: fix use of uninitialized variable drm/framebuffer: Fix use of uninitialized variable
drivers/gpu/drm/drm_file.c | 2 +- drivers/gpu/drm/drm_framebuffer.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
---
base-commit: b0e9267d4ccce9be9217337f4bc364ca24cf7f73
change-id: 20230804-uninit-fixes-188f92d60ac3
Best regards,
Signature · 1 line
Tomi Valkeinen <[email protected]>
PATCH 1/2 drm/drm_file: fix use of uninitialized variable
smatch reports:
drivers/gpu/drm/drm_file.c:967 drm_show_memory_stats() error: uninitialized symbol 'supported_status'.
'supported_status' is only set in one code path. I'm not familiar with the code to say if that path will always be ran in real life, but whether that is the case or not, I think it is good to initialize 'supported_status' to 0 to silence the warning (and possibly fix a bug).
--- drivers/gpu/drm/drm_file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_file.c +1 -1
@@ -924,7 +924,7 @@ void drm_show_memory_stats(struct drm_printer *p, struct drm_file *file) {struct drm_gem_object *obj;struct drm_memory_stats status = {}; -enum drm_gem_object_status supported_status; +enum drm_gem_object_status supported_status =0 ;int id;spin_lock (&file->table_lock);
Signature · 1 line
2.34.1
Re: [PATCH 1/2] drm/drm_file: fix use of uninitialized variable
Quoted 10 lines · Tomi Valkeinen
smatch reports:
drivers/gpu/drm/drm_file.c:967drm_show_memory_stats()error: uninitialized symbol 'supported_status'.'
supported_status' is only set in one code path. I'm not familiar with the code to say if that path will always be ran in real life, but whether that is the case or not, I think it is good to initialize 'supported_status' to 0 to silence the warning (and possibly fix a bug).Signed-off-by Tomi Valkeinen <[email protected]>
Quoted 18 lines
--- drivers/gpu/drm/drm_file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/drm_file.c +1
-1@@ -924,7 +924,7 @@ void drm_show_memory_stats(struct drm_printer *p, struct drm_file *file) {struct drm_gem_object *obj;struct drm_memory_stats status = {}; -enum drm_gem_object_status supported_status; +enum drm_gem_object_status supported_status =0 ;int id;spin_lock (&file->table_lock);
Signature · 3 lines
Regards, Laurent Pinchart
PATCH 2/2 drm/framebuffer: Fix use of uninitialized variable
In reply to Tomi Valkeinensmatch 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.
--- drivers/gpu/drm/drm_framebuffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_framebuffer.c +1 -1
@@ -570,7 +570,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 ;
Signature · 1 line
2.34.1
Re: [PATCH 2/2] drm/framebuffer: Fix use of uninitialized variable
Quoted 7 lines · Tomi Valkeinen
smatch reports:
drivers/gpu/drm/drm_framebuffer.c:654drm_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.
I don't think it can happen in practice, but tools have no way to know that.
Quoted 19 lines
Signed-off-by Tomi Valkeinen <[email protected]>--- drivers/gpu/drm/drm_framebuffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/drm_framebuffer.c +1
-1@@ -570,7 +570,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 ;
Signature · 3 lines
Regards, Laurent Pinchart