Re: [PATCH v7 2/8] media: uvcvideo: Add support for per-device control mapping overrides

From: Dan Carpenter
Date: Fri Jul 01 2022 - 03:27:09 EST


On Fri, Jul 01, 2022 at 01:16:23AM +0200, Ricardo Ribalda wrote:
> >
> > "mapping" uninitialized if chain->dev->info->mappings is NULL.
> >
> > 10bdca4191d7a8 drivers/media/usb/uvc/uvc_ctrl.c Ricardo Ribalda 2022-06-17 2457
> > 10bdca4191d7a8 drivers/media/usb/uvc/uvc_ctrl.c Ricardo Ribalda 2022-06-17 2458 /* Process common mappings next. */
> > 10bdca4191d7a8 drivers/media/usb/uvc/uvc_ctrl.c Ricardo Ribalda 2022-06-17 @2459 mend = mapping + ARRAY_SIZE(uvc_ctrl_mappings);
> > ^^^^^^^
> >
> > 10bdca4191d7a8 drivers/media/usb/uvc/uvc_ctrl.c Ricardo Ribalda 2022-06-17 2460 for (mapping = uvc_ctrl_mappings; mapping < mend; ++mapping) {
> >
> > I'm surprised this made it through testing... Anyway, the easier way to
> > to iterate through an array of structs is just say:
>
> There is already a new version under review that fixes this:
>
> https://patchwork.linuxtv.org/project/linux-media/patch/20220617235610.321917-3-ribalda@xxxxxxxxxxxx/
>
>
> >
> > for (i = 0; i < ARRAY_SIZE(uvc_ctrl_mappings); i++) {
> > mapping = &uvc_ctrl_mappings[i];
> >
>
> I agree, and that is what I normally used, but that driver iterate this way...

That's not really an excuse. Imagine you were a lemming and Disney
employees were trying to chase you off a cliff!

>
> Thanks again!
>
> PS: Any idea why the test was triggered 14+ days after the patch was sent?

I don't know how kbuild works. I run Smatch on linux-next so I would
have caught it eventually. Plus the clang people would have caught it.

regards,
dan carpenter