@@ -121,6 +121,9 @@ static struct uvcg_format *find_format_by_pix(struct uvc_device *uvc,
121
121
list_for_each_entry (format , & uvc -> header -> formats , entry ) {
122
122
struct uvc_format_desc * fmtdesc = to_uvc_format (format -> fmt );
123
123
124
+ if (IS_ERR (fmtdesc ))
125
+ continue ;
126
+
124
127
if (fmtdesc -> fcc == pixelformat ) {
125
128
uformat = format -> fmt ;
126
129
break ;
@@ -240,6 +243,7 @@ uvc_v4l2_try_format(struct file *file, void *fh, struct v4l2_format *fmt)
240
243
struct uvc_video * video = & uvc -> video ;
241
244
struct uvcg_format * uformat ;
242
245
struct uvcg_frame * uframe ;
246
+ const struct uvc_format_desc * fmtdesc ;
243
247
u8 * fcc ;
244
248
245
249
if (fmt -> type != video -> queue .queue .type )
@@ -265,7 +269,10 @@ uvc_v4l2_try_format(struct file *file, void *fh, struct v4l2_format *fmt)
265
269
fmt -> fmt .pix .field = V4L2_FIELD_NONE ;
266
270
fmt -> fmt .pix .bytesperline = uvc_v4l2_get_bytesperline (uformat , uframe );
267
271
fmt -> fmt .pix .sizeimage = uvc_get_frame_size (uformat , uframe );
268
- fmt -> fmt .pix .pixelformat = to_uvc_format (uformat )-> fcc ;
272
+ fmtdesc = to_uvc_format (uformat );
273
+ if (IS_ERR (fmtdesc ))
274
+ return PTR_ERR (fmtdesc );
275
+ fmt -> fmt .pix .pixelformat = fmtdesc -> fcc ;
269
276
fmt -> fmt .pix .colorspace = V4L2_COLORSPACE_SRGB ;
270
277
fmt -> fmt .pix .priv = 0 ;
271
278
@@ -378,6 +385,9 @@ uvc_v4l2_enum_format(struct file *file, void *fh, struct v4l2_fmtdesc *f)
378
385
f -> flags |= V4L2_FMT_FLAG_COMPRESSED ;
379
386
380
387
fmtdesc = to_uvc_format (uformat );
388
+ if (IS_ERR (fmtdesc ))
389
+ return PTR_ERR (fmtdesc );
390
+
381
391
f -> pixelformat = fmtdesc -> fcc ;
382
392
383
393
strscpy (f -> description , fmtdesc -> name , sizeof (f -> description ));
0 commit comments