Skip to contentSkip to conversation

media: cxusb: fix uninitialized var in cxusb_gpio_tuner()

PATCH In review Penglei Jiang 2 participants 2 messages Apr 5, 2025 – Apr 25, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 media: cxusb: fix uninitialized var in cxusb_gpio_tuner()

The function cxusb_ctrl_msg() may not set the value of the variable i, but the code uses it later. Initialize the local variable i to 0 to prevent potential issues.

---
V1 -> V2: Updated the Subject

 drivers/media/usb/dvb-usb/cxusb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/usb/dvb-usb/cxusb.c +1 -1
index f44529b40989..7fe858bb665e 100644
@@ -111,7 +111,7 @@ int cxusb_ctrl_msg(struct dvb_usb_device *d,
 static void cxusb_gpio_tuner(struct dvb_usb_device *d, int onoff)
 {
 	struct cxusb_state *st = d->priv;
-	u8 o[2], i;
+	u8 o[2], i = 0;
 
 	if (st->gpio_write_state[GPIO_TUNER] == onoff &&
 	    !st->gpio_write_refresh[GPIO_TUNER])
Signature · 1 line
2.17.1
#1 lore raw

Hi Penglei Jiang.

Quoted 7 lines · Penglei Jiang

The function cxusb_ctrl_msg() may not set the value of the variable i, but the code uses it later. Initialize the local variable i to 0 to prevent potential issues.

FYI: I marked this as Obsolete since this patch is a better solution:

https://patchwork.linuxtv.org/project/linux-media/patch/[email protected]/

Regards,

Hans

Quoted 19 lines

---
V1 -> V2: Updated the Subject

 drivers/media/usb/dvb-usb/cxusb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/usb/dvb-usb/cxusb.c +1 -1
index f44529b40989..7fe858bb665e 100644
@@ -111,7 +111,7 @@ int cxusb_ctrl_msg(struct dvb_usb_device *d,
 static void cxusb_gpio_tuner(struct dvb_usb_device *d, int onoff)
 {
 	struct cxusb_state *st = d->priv;
-	u8 o[2], i;
+	u8 o[2], i = 0;
 
 	if (st->gpio_write_state[GPIO_TUNER] == onoff &&
 	    !st->gpio_write_refresh[GPIO_TUNER])