Commit a350cfb6 authored by Michael Grzeschik's avatar Michael Grzeschik Committed by Greg Kroah-Hartman

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: default avatarMichael Grzeschik <m.grzeschik@pengutronix.de>

Link: https://lore.kernel.org/r/20220421211427.3400834-4-m.grzeschik@pengutronix.deSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 4a7ffc10
...@@ -1565,6 +1565,12 @@ uvcg_uncompressed_##cname##_store(struct config_item *item, \ ...@@ -1565,6 +1565,12 @@ uvcg_uncompressed_##cname##_store(struct config_item *item, \
if (ret) \ if (ret) \
goto end; \ goto end; \
\ \
/* index values in uvc are never 0 */ \
if (!num) { \
ret = -EINVAL; \
goto end; \
} \
\
u->desc.aname = num; \ u->desc.aname = num; \
ret = len; \ ret = len; \
end: \ end: \
...@@ -1758,6 +1764,12 @@ uvcg_mjpeg_##cname##_store(struct config_item *item, \ ...@@ -1758,6 +1764,12 @@ uvcg_mjpeg_##cname##_store(struct config_item *item, \
if (ret) \ if (ret) \
goto end; \ goto end; \
\ \
/* index values in uvc are never 0 */ \
if (!num) { \
ret = -EINVAL; \
goto end; \
} \
\
u->desc.aname = num; \ u->desc.aname = num; \
ret = len; \ ret = len; \
end: \ end: \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment