Skip to content

Commit

Permalink
usb: gadget: uvc: prevent index variables to start from 0
Browse files Browse the repository at this point in the history
Some configfs variables like bDefaultFrameIndex are always starting by
1. This patch adds a check to prevent setting those variables to 0.

Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>

Link: https://lore.kernel.org/r/20220421211427.3400834-4-m.grzeschik@pengutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Michael Grzeschik authored and Greg Kroah-Hartman committed May 5, 2022
1 parent 4a7ffc1 commit a350cfb
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions drivers/usb/gadget/function/uvc_configfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1565,6 +1565,12 @@ uvcg_uncompressed_##cname##_store(struct config_item *item, \
if (ret) \
goto end; \
\
/* index values in uvc are never 0 */ \
if (!num) { \
ret = -EINVAL; \
goto end; \
} \
\
u->desc.aname = num; \
ret = len; \
end: \
Expand Down Expand Up @@ -1758,6 +1764,12 @@ uvcg_mjpeg_##cname##_store(struct config_item *item, \
if (ret) \
goto end; \
\
/* index values in uvc are never 0 */ \
if (!num) { \
ret = -EINVAL; \
goto end; \
} \
\
u->desc.aname = num; \
ret = len; \
end: \
Expand Down

0 comments on commit a350cfb

Please sign in to comment.