usb: gadget: uvc: prevent index variables to start from 0

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>
This commit is contained in:
Michael Grzeschik 2022-04-21 23:14:23 +02:00 committed by Greg Kroah-Hartman
parent 4a7ffc10d1
commit a350cfb653

View File

@ -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: \
@ -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: \