UPSTREAM: 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> (cherry picked from commit a350cfb6537f94be8a6423bc68a7a7883263c306) Bug: 242344221 Change-Id: Ieb800223fe0071c7a3650b146a1d0c6f5f7ad8a2 Signed-off-by: Avichal Rakesh <arakesh@google.com> (cherry picked from commit fc33d1de5c0afbee9355448e4e634c0bdea558e6)
This commit is contained in:
committed by
Treehugger Robot
parent
413bfd5f1b
commit
e5fe1a95c3
@@ -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: \
|
||||
|
||||
Reference in New Issue
Block a user