diff mbox

[1/2] gspca_kinect: fix kinect_read() error path

Message ID 1388421706-8366-1-git-send-email-ospite@studenti.unina.it (mailing list archive)
State New, archived
Headers show

Commit Message

Antonio Ospite Dec. 30, 2013, 4:41 p.m. UTC
The error checking code relative to the invocations of kinect_read()
does not return the actual return code of the function just called, it
returns "res" which still contains the value of the last invocation of
a previous kinect_write().

Return the proper value, and while at it also report with -EREMOTEIO the
case of a partial transfer.

Reported-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Antonio Ospite <ospite@studenti.unina.it>
---
 drivers/media/usb/gspca/kinect.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Hans de Goede Feb. 23, 2014, 9:45 p.m. UTC | #1
Hi,

Thanks I've added both to my gspca tree for 3.15

Regards,

Hans


On 12/30/2013 05:41 PM, Antonio Ospite wrote:
> The error checking code relative to the invocations of kinect_read()
> does not return the actual return code of the function just called, it
> returns "res" which still contains the value of the last invocation of
> a previous kinect_write().
> 
> Return the proper value, and while at it also report with -EREMOTEIO the
> case of a partial transfer.
> 
> Reported-by: Julia Lawall <julia.lawall@lip6.fr>
> Signed-off-by: Antonio Ospite <ospite@studenti.unina.it>
> ---
>  drivers/media/usb/gspca/kinect.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/usb/gspca/kinect.c b/drivers/media/usb/gspca/kinect.c
> index 3773a8a..48084736 100644
> --- a/drivers/media/usb/gspca/kinect.c
> +++ b/drivers/media/usb/gspca/kinect.c
> @@ -158,7 +158,7 @@ static int send_cmd(struct gspca_dev *gspca_dev, uint16_t cmd, void *cmdbuf,
>  	PDEBUG(D_USBO, "Control reply: %d", res);
>  	if (actual_len < sizeof(*rhdr)) {
>  		pr_err("send_cmd: Input control transfer failed (%d)\n", res);
> -		return res;
> +		return actual_len < 0 ? actual_len : -EREMOTEIO;
>  	}
>  	actual_len -= sizeof(*rhdr);
>  
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/media/usb/gspca/kinect.c b/drivers/media/usb/gspca/kinect.c
index 3773a8a..48084736 100644
--- a/drivers/media/usb/gspca/kinect.c
+++ b/drivers/media/usb/gspca/kinect.c
@@ -158,7 +158,7 @@  static int send_cmd(struct gspca_dev *gspca_dev, uint16_t cmd, void *cmdbuf,
 	PDEBUG(D_USBO, "Control reply: %d", res);
 	if (actual_len < sizeof(*rhdr)) {
 		pr_err("send_cmd: Input control transfer failed (%d)\n", res);
-		return res;
+		return actual_len < 0 ? actual_len : -EREMOTEIO;
 	}
 	actual_len -= sizeof(*rhdr);