media: sq905.c: fix uninitialized variable
Subsystems (2)
PATCH v2 1/1 media: sq905.c: fix uninitialized variable
---
Changes in v2:
- Fix the error occured because of pervious fix.
--- drivers/media/usb/gspca/sq905.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/media/usb/gspca/sq905.c +4 -4
@@ -157,8 +157,8 @@ static int sq905_ack_frame(struct gspca_dev *gspca_dev)static int sq905_read_data (struct gspca_dev *gspca_dev,u8 *data,int size,int need_lock) { -int ret; -int act_len; +int ret; +int act_len; gspca_dev->usb_buf[0 ] ='\0' ;if (need_lock)
@@ -180,8 +180,8 @@ sq905_read_data(struct gspca_dev *gspca_dev, u8 *data, int size, int need_lock) data, size, &act_len, SQ905_DATA_TIMEOUT);/* successful, it returns 0, otherwise negative */ -if (ret <0 || act_len != size) { -pr_err ("bulk read fail (%d) len %d/%d\n" , ret, act_len, size); +if (ret <0 || act_len != size) { +pr_err ("bulk read fail (%d) len %d/%d\n" , ret, ret <0 ?-1 : act_len, size);return -EIO ; }return 0 ;
Signature · 1 line
2.25.1
Hi!
Quoted 34 lines · Alaa Emad
Reported-by [email protected]Signed-off-by Alaa Emad <[email protected]>---
Changes in v2:
- Fix the error occured because of pervious fix.
---
drivers/media/usb/gspca/sq905.c | 8 ++++----1 file changed, 4 insertions(+), 4 deletions(-)drivers/media/usb/gspca/sq905.c +0
-0@@ -157,8 +157,8 @@ static int sq905_ack_frame(struct gspca_dev *gspca_dev)static int
sq905_read_data(structgspca_dev*gspca_dev, u8 *data, int size, intneed_lock)
{
- int ret;
- intact_len;
+ int ret;
+ intact_len;
gspca_dev->usb_buf[0] = '\0';
if (need_lock)drivers/media/usb/gspca/sq905.c +0
-0@@ -180,8 +180,8 @@ sq905_read_data(struct gspca_dev *gspca_dev, u8 *data, int size, int need_lock) data, size, &act_len, SQ905_DATA_TIMEOUT);
/* successful, it returns 0, otherwise negative */ - if (ret < 0 ||act_len!= size) {
Quoted 11 lines
- pr_err("bulk read fail (%d) len %d/%d\n", ret,
act_len, size);
+ if (ret < 0 ||act_len!= size) {
+pr_err("bulk read fail (%d) len %d/%d\n", ret, ret < 0 ? -1 : act_len, size);
return-EIO;
}
return 0;Signature · 1 line
2.25.1
I skimmed through code, and I'm not sure about Dmitry's approach, because I think usb_submit_urb() can return some valid urb-
Quoted 1 line
actual_lengthand error code:
if (!wait_for_completion_timeout(&ctx.done, expire)) {
usb_kill_urb(urb);
retval = (ctx.status == -ENOENT ? -ETIMEDOUT :ctx.status);
dev_dbg(&urb->dev->dev, "%s timed out on ep%d%s len=%u/%u\n", current->comm, usb_endpoint_num(&urb->ep->desc), usb_urb_dir_in(urb) ? "in" : "out", urb->actual_length, urb->transfer_buffer_length); } else retval = ctx.status; ... if (actual_length) *actual_length = urb->actual_length;
I believe, that this info might be useful.
Im not sure about it, i didn't found any examples of this log and have no idea how to reproduce it, it's just my thoughts. Maybe, one of the maintainers will correct me
Signature · 2 lines
With regards, Pavel Skripkin
Hi Alaa,
FYI: this patch has already been applied to the media_tree master git repo:
https://patchwork.linuxtv.org/project/linux-media/patch/[email protected]/
That's good enough for this issue so I am marking this patch as Obsolete in our patchwork.
Quoted 26 lines · Alaa Emad
Reported-by [email protected]Signed-off-by Alaa Emad <[email protected]>---
Changes in v2:
- Fix the error occured because of pervious fix.--- drivers/media/usb/gspca/sq905.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/media/usb/gspca/sq905.c +2
-2@@ -157,8 +157,8 @@ static int sq905_ack_frame(struct gspca_dev *gspca_dev)static int sq905_read_data (struct gspca_dev *gspca_dev,u8 *data,int size,int need_lock) { -int ret; -int act_len; +int ret; +int act_len; gspca_dev->usb_buf[0 ] ='\0' ;if (need_lock)
drivers/media/usb/gspca/sq905.c sq905_read_data(struct gspca_dev *gspca_dev, u8 *data, int size, int need_lock) · line 184
Quoted 7 lines
drivers/media/usb/gspca/sq905.c +2
-2@@ -180,8 +180,8 @@ sq905_read_data(struct gspca_dev *gspca_dev, u8 *data, int size, int need_lock) data, size, &act_len, SQ905_DATA_TIMEOUT);/* successful, it returns 0, otherwise negative */ -if (ret <0 || act_len != size) { -pr_err ("bulk read fail (%d) len %d/%d\n" , ret, act_len, size); +if (ret <0 || act_len != size) { +pr_err ("bulk read fail (%d) len %d/%d\n" , ret, ret <0 ?-1 : act_len, size);
General note: it looks like you are replacing tab characters with spaces. Make sure you configure your editor not to do that.
Regards,
Hans
Quoted 4 lines
drivers/media/usb/gspca/sq905.c +0
-0return -EIO ; }return 0 ;