Re: [PATCH v2 08/26] media: v4l2-async: shut up an unitialized symbol warning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi folks,

On Tue, Dec 12, 2017 at 12:13:59AM +0200, Laurent Pinchart wrote:
> Hi Mauro,
> 
> On Monday, 11 December 2017 20:10:58 EET Mauro Carvalho Chehab wrote:
> > Em Thu, 02 Nov 2017 04:51:40 +0200 Laurent Pinchart escreveu:
> > > On Wednesday, 1 November 2017 23:05:45 EET Mauro Carvalho Chehab wrote:
> > >> Smatch reports this warning:
> > >> 	drivers/media/v4l2-core/v4l2-async.c:597 v4l2_async_register_subdev()
> > >> 
> > >> error: uninitialized symbol 'ret'.
> > >> 
> > >> However, there's nothing wrong there. So, just shut up the
> > >> warning.
> > > 
> > > Nothing wrong, really ? ret does seem to be used uninitialized when the
> > > function returns at the very last line.
> > 
> > There's nothing wrong. If you follow the logic, you'll see that
> > the line:
> > 
> > 	return ret;
> > 
> > is called only at "err_unbind" label, with is called only on
> > two places:
> > 
> >                 ret = v4l2_async_match_notify(notifier, v4l2_dev, sd, asd);
> >                 if (ret)
> >                         goto err_unbind;
> > 
> >                 ret = v4l2_async_notifier_try_complete(notifier);
> >                 if (ret)
> >                         goto err_unbind;
> > 
> > There, ret is defined.
> > 
> > Yeah, the logic there is confusing.
> 
> I had missed the return 0 just before the error label. Sorry for the noise.

I believe the matter has been addressed by this patch:

commit 580db6ca62c168733c6fd338cd2f0ebf39135283
Author: Colin Ian King <colin.king@xxxxxxxxxxxxx>
Date:   Fri Nov 3 02:58:27 2017 -0400

    media: v4l: async: fix return of unitialized variable ret
    
    A shadow declaration of variable ret is being assigned a return error
    status and this value is being lost when the error exit goto's jump
    out of the local scope. This leads to an uninitalized error return value
    in the outer scope being returned. Fix this by removing the inner scoped
    declaration of variable ret.
    
    Detected by CoverityScan, CID#1460380 ("Uninitialized scalar variable")
    
    Fixes: fb45f436b818 ("media: v4l: async: Fix notifier complete callback error handling")
    
    Signed-off-by: Colin Ian King <colin.king@xxxxxxxxxxxxx>
    Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@xxxxxxxxxxxx>
    Signed-off-by: Sakari Ailus <sakari.ailus@xxxxxxxxxxxxxxx>
    Signed-off-by: Mauro Carvalho Chehab <mchehab@xxxxxxxxxxxxxxxx>

-- 
Sakari Ailus
e-mail: sakari.ailus@xxxxxx



[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux