Linux ARM-MSM sub-architecture
 help / color / mirror / Atom feed
* [PATCH] drm/msm: return early when allocating fbdev fails
@ 2023-02-22 15:56 Tom Rix
  2023-02-22 16:09 ` Thomas Zimmermann
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Rix @ 2023-02-22 15:56 UTC (permalink / raw)
  To: robdclark, quic_abhinavk, dmitry.baryshkov, sean, airlied, daniel,
	nathan, ndesaulniers, tzimmermann, javierm
  Cc: linux-arm-msm, dri-devel, freedreno, linux-kernel, llvm, 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@redhat.com>
---
 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;
 
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/msm: return early when allocating fbdev fails
  2023-02-22 15:56 [PATCH] drm/msm: return early when allocating fbdev fails Tom Rix
@ 2023-02-22 16:09 ` Thomas Zimmermann
  2023-02-22 18:21   ` Nathan Chancellor
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Zimmermann @ 2023-02-22 16:09 UTC (permalink / raw)
  To: Tom Rix, robdclark, quic_abhinavk, dmitry.baryshkov, sean,
	airlied, daniel, nathan, ndesaulniers, javierm
  Cc: linux-arm-msm, llvm, linux-kernel, dri-devel, freedreno


[-- Attachment #1.1: Type: text/plain, Size: 1481 bytes --]

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@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

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/msm: return early when allocating fbdev fails
  2023-02-22 16:09 ` Thomas Zimmermann
@ 2023-02-22 18:21   ` Nathan Chancellor
  0 siblings, 0 replies; 3+ messages in thread
From: Nathan Chancellor @ 2023-02-22 18:21 UTC (permalink / raw)
  To: Thomas Zimmermann
  Cc: Tom Rix, robdclark, quic_abhinavk, dmitry.baryshkov, sean,
	airlied, daniel, ndesaulniers, javierm, linux-arm-msm, llvm,
	linux-kernel, dri-devel, freedreno

On Wed, Feb 22, 2023 at 05:09:40PM +0100, Thomas Zimmermann wrote:
> 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@redhat.com>
> 
> Already fixed here: https://lore.kernel.org/dri-devel/08e3340e-b459-0e60-4bba-30716b675e05@suse.de/T/#t

There is also:

../drivers/gpu/drm/omapdrm/omap_fbdev.c:235:6: error: variable 'helper' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]
        if (!fbdev)
            ^~~~~~
../drivers/gpu/drm/omapdrm/omap_fbdev.c:259:26: note: uninitialized use occurs here
        drm_fb_helper_unprepare(helper);
                                ^~~~~~
../drivers/gpu/drm/omapdrm/omap_fbdev.c:235:2: note: remove the 'if' if its condition is always false
        if (!fbdev)
        ^~~~~~~~~~~
../drivers/gpu/drm/omapdrm/omap_fbdev.c:228:30: note: initialize the variable 'helper' to silence this warning
        struct drm_fb_helper *helper;
                                    ^
                                     = NULL
1 error generated.

Is the fix the same as the one you have linked above?

Cheers,
Nathan

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-02-22 18:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-22 15:56 [PATCH] drm/msm: return early when allocating fbdev fails Tom Rix
2023-02-22 16:09 ` Thomas Zimmermann
2023-02-22 18:21   ` Nathan Chancellor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox