Re: [PATCH] media: v4l2-subdev: Fix a 64bit bug

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

 



Hi Dan,

On Fri, Nov 03, 2023 at 10:24:40AM +0300, Dan Carpenter wrote:
> On Fri, Nov 03, 2023 at 07:00:01AM +0000, Sakari Ailus wrote:
> > Hi Dan,
> > 
> > Thanks for the patch.
> > 
> > On Fri, Nov 03, 2023 at 09:34:25AM +0300, Dan Carpenter wrote:
> > > The problem is this line here from subdev_do_ioctl().
> > > 
> > > 	client_cap->capabilities &= ~V4L2_SUBDEV_CLIENT_CAP_STREAMS;
> > > 
> > > The "client_cap->capabilities" variable is a u64.  The AND operation
> > > is supposed to clear out the V4L2_SUBDEV_CLIENT_CAP_STREAMS flag.  But
> > > because it's a 32 bit variable it accidentally clears our the high 32
> > > bits as well.
> > > 
> > > Currently we only use BIT(0) and none ofthe upper bits so this doesn't
> > > affect runtime behavior.
> > > 
> > > Fixes: f57fa2959244 ("media: v4l2-subdev: Add new ioctl for client capabilities")
> > > Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
> > > ---
> > >  include/uapi/linux/v4l2-subdev.h | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/include/uapi/linux/v4l2-subdev.h b/include/uapi/linux/v4l2-subdev.h
> > > index 4a195b68f28f..21d149969119 100644
> > > --- a/include/uapi/linux/v4l2-subdev.h
> > > +++ b/include/uapi/linux/v4l2-subdev.h
> > > @@ -239,7 +239,7 @@ struct v4l2_subdev_routing {
> > >   * set (which is the default), the 'stream' fields will be forced to 0 by the
> > >   * kernel.
> > >   */
> > > - #define V4L2_SUBDEV_CLIENT_CAP_STREAMS		(1U << 0)
> > > + #define V4L2_SUBDEV_CLIENT_CAP_STREAMS		BIT_ULL(0)
> > 
> > This is a UAPI header but BIT_ULL() is defined in kernel-only headers.
> > 
> > So (1ULL << 0) ?
> > 
> > uapi/linux/const.h also has _BITULL().
> 
> Let's just do 1ULL < 0.  I'll resend.  Is there an automated way I could
> have caught this?

I don't know. :-) Remember to use shift left for bit definitions in UAPI
headers?

-- 
Regards,

Sakari Ailus



[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