[PATCH] drm/msm: return early when allocating fbdev fails

Thomas Zimmermann tzimmermann at suse.de
Wed Feb 22 16:09:40 UTC 2023


Hi

Am 22.02.23 um 16:56 schrieb Tom Rix:
> building with clang and W=1 reports
> drivers/gpu/drm/msm/msm_fbdev.c:144:6: error: variable 'helper' is used
>    uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]
>    if (!fbdev)
>        ^~~~~~
> 
> helper is only initialized after fbdev succeeds, so is in a garbage state at
> the fail: label.  There is nothing to unwinded if fbdev alloaction fails,
> return NULL.
> 
> Fixes: 3fb1f62f80a1 ("drm/fb-helper: Remove drm_fb_helper_unprepare() from drm_fb_helper_fini()")
> Signed-off-by: Tom Rix <trix at redhat.com>

Already fixed here: 
https://lore.kernel.org/dri-devel/08e3340e-b459-0e60-4bba-30716b675e05@suse.de/T/#t

Best regards
Thomas

> ---
>   drivers/gpu/drm/msm/msm_fbdev.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/msm/msm_fbdev.c b/drivers/gpu/drm/msm/msm_fbdev.c
> index c804e5ba682a..c1356aff87da 100644
> --- a/drivers/gpu/drm/msm/msm_fbdev.c
> +++ b/drivers/gpu/drm/msm/msm_fbdev.c
> @@ -142,7 +142,7 @@ struct drm_fb_helper *msm_fbdev_init(struct drm_device *dev)
>   
>   	fbdev = kzalloc(sizeof(*fbdev), GFP_KERNEL);
>   	if (!fbdev)
> -		goto fail;
> +		return NULL;
>   
>   	helper = &fbdev->base;
>   

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 840 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/dri-devel/attachments/20230222/0fc132f5/attachment.sig>


More information about the dri-devel mailing list