diff mbox series

drm/vc4: fix uninitialized smatch warnings

Message ID 20250405024503.694981-1-sunliming@linux.dev (mailing list archive)
State New
Headers show
Series drm/vc4: fix uninitialized smatch warnings | expand

Commit Message

Sunliming April 5, 2025, 2:45 a.m. UTC
From: sunliming <sunliming@kylinos.cn>

Fix below smatch warnings:
drivers/gpu/drm/vc4/vc4_gem.c:604 vc4_lock_bo_reservations() error: uninitialized symbol 'ret'.

Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/r/202504021500.3AM1hKKS-lkp@intel.com/
Signed-off-by: sunliming <sunliming@kylinos.cn>
---
 drivers/gpu/drm/vc4/vc4_gem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Maxime Ripard April 7, 2025, 7:13 a.m. UTC | #1
On Sat, Apr 05, 2025 at 10:45:03AM +0800, sunliming@linux.dev wrote:
> From: sunliming <sunliming@kylinos.cn>
> 
> Fix below smatch warnings:
> drivers/gpu/drm/vc4/vc4_gem.c:604 vc4_lock_bo_reservations() error: uninitialized symbol 'ret'.
> 
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> Closes: https://lore.kernel.org/r/202504021500.3AM1hKKS-lkp@intel.com/
> Signed-off-by: sunliming <sunliming@kylinos.cn>
> ---
>  drivers/gpu/drm/vc4/vc4_gem.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/vc4/vc4_gem.c b/drivers/gpu/drm/vc4/vc4_gem.c
> index 8125f87edc60..04ea1696fc5d 100644
> --- a/drivers/gpu/drm/vc4/vc4_gem.c
> +++ b/drivers/gpu/drm/vc4/vc4_gem.c
> @@ -582,7 +582,7 @@ static int
>  vc4_lock_bo_reservations(struct vc4_exec_info *exec,
>  			 struct drm_exec *exec_ctx)
>  {
> -	int ret;
> +	int ret = 0;
>  
>  	/* Reserve space for our shared (read-only) fence references,
>  	 * before we commit the CL to the hardware.

I don't see a code path where ret is used without being initialized. Can
you clarify that in the commit log?

Maxime
Dan Carpenter April 7, 2025, 8:56 a.m. UTC | #2
On Mon, Apr 07, 2025 at 09:13:59AM +0200, Maxime Ripard wrote:
> On Sat, Apr 05, 2025 at 10:45:03AM +0800, sunliming@linux.dev wrote:
> > From: sunliming <sunliming@kylinos.cn>
> > 
> > Fix below smatch warnings:
> > drivers/gpu/drm/vc4/vc4_gem.c:604 vc4_lock_bo_reservations() error: uninitialized symbol 'ret'.
> > 
> > Reported-by: kernel test robot <lkp@intel.com>
> > Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> > Closes: https://lore.kernel.org/r/202504021500.3AM1hKKS-lkp@intel.com/
> > Signed-off-by: sunliming <sunliming@kylinos.cn>
> > ---
> >  drivers/gpu/drm/vc4/vc4_gem.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/gpu/drm/vc4/vc4_gem.c b/drivers/gpu/drm/vc4/vc4_gem.c
> > index 8125f87edc60..04ea1696fc5d 100644
> > --- a/drivers/gpu/drm/vc4/vc4_gem.c
> > +++ b/drivers/gpu/drm/vc4/vc4_gem.c
> > @@ -582,7 +582,7 @@ static int
> >  vc4_lock_bo_reservations(struct vc4_exec_info *exec,
> >  			 struct drm_exec *exec_ctx)
> >  {
> > -	int ret;
> > +	int ret = 0;
> >  
> >  	/* Reserve space for our shared (read-only) fence references,
> >  	 * before we commit the CL to the hardware.
> 
> I don't see a code path where ret is used without being initialized. Can
> you clarify that in the commit log?

Apparently the drm_exec_until_all_locked() loop always iterates at least
once.  If you have the cross function database then this is parsed
automatically, but I've also hard coded it as a loop at least once macro
just a 1 minute ago to silence this false positive.s

regards,
dan carpenter
diff mbox series

Patch

diff --git a/drivers/gpu/drm/vc4/vc4_gem.c b/drivers/gpu/drm/vc4/vc4_gem.c
index 8125f87edc60..04ea1696fc5d 100644
--- a/drivers/gpu/drm/vc4/vc4_gem.c
+++ b/drivers/gpu/drm/vc4/vc4_gem.c
@@ -582,7 +582,7 @@  static int
 vc4_lock_bo_reservations(struct vc4_exec_info *exec,
 			 struct drm_exec *exec_ctx)
 {
-	int ret;
+	int ret = 0;
 
 	/* Reserve space for our shared (read-only) fence references,
 	 * before we commit the CL to the hardware.