linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] [media] af9035: fix missing unlock on error in af9035_ctrl_msg()
@ 2013-03-26  5:32 Wei Yongjun
  2013-03-26  9:46 ` Antti Palosaari
  0 siblings, 1 reply; 3+ messages in thread
From: Wei Yongjun @ 2013-03-26  5:32 UTC (permalink / raw)
  To: crope, mchehab; +Cc: yongjun_wei, linux-media

From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>

Add the missing unlock before return from function af9035_ctrl_msg()
in the error handling case.

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
---
 drivers/media/usb/dvb-usb-v2/af9035.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c b/drivers/media/usb/dvb-usb-v2/af9035.c
index b1f7059..b638fc1 100644
--- a/drivers/media/usb/dvb-usb-v2/af9035.c
+++ b/drivers/media/usb/dvb-usb-v2/af9035.c
@@ -57,7 +57,7 @@ static int af9035_ctrl_msg(struct dvb_usb_device *d, struct usb_req *req)
 		dev_err(&d->udev->dev, "%s: too much data wlen=%d rlen=%d\n",
 				__func__, req->wlen, req->rlen);
 		ret = -EINVAL;
-		goto err;
+		goto exit;
 	}
 
 	state->buf[0] = REQ_HDR_LEN + req->wlen + CHECKSUM_LEN - 1;
@@ -81,7 +81,7 @@ static int af9035_ctrl_msg(struct dvb_usb_device *d, struct usb_req *req)
 	ret = dvb_usbv2_generic_rw_locked(d,
 			state->buf, wlen, state->buf, rlen);
 	if (ret)
-		goto err;
+		goto exit;
 
 	/* no ack for those packets */
 	if (req->cmd == CMD_FW_DL)
@@ -95,28 +95,29 @@ static int af9035_ctrl_msg(struct dvb_usb_device *d, struct usb_req *req)
 				"(%04x != %04x)\n", KBUILD_MODNAME, req->cmd,
 				tmp_checksum, checksum);
 		ret = -EIO;
-		goto err;
+		goto exit;
 	}
 
 	/* check status */
 	if (state->buf[2]) {
 		/* fw returns status 1 when IR code was not received */
-		if (req->cmd == CMD_IR_GET || state->buf[2] == 1)
-			return 1;
+		if (req->cmd == CMD_IR_GET || state->buf[2] == 1) {
+			ret = 1;
+			goto exit;
+		}
 
 		dev_dbg(&d->udev->dev, "%s: command=%02x failed fw error=%d\n",
 				__func__, req->cmd, state->buf[2]);
 		ret = -EIO;
-		goto err;
+		goto exit;
 	}
 
 	/* read request, copy returned data to return buf */
 	if (req->rlen)
 		memcpy(req->rbuf, &state->buf[ACK_HDR_LEN], req->rlen);
 exit:
-err:
 	mutex_unlock(&d->usb_mutex);
-	if (ret)
+	if (ret < 0)
 		dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret);
 	return ret;
 }



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH -next] [media] af9035: fix missing unlock on error in af9035_ctrl_msg()
  2013-03-26  5:32 [PATCH -next] [media] af9035: fix missing unlock on error in af9035_ctrl_msg() Wei Yongjun
@ 2013-03-26  9:46 ` Antti Palosaari
  2013-03-26 10:00   ` Antti Palosaari
  0 siblings, 1 reply; 3+ messages in thread
From: Antti Palosaari @ 2013-03-26  9:46 UTC (permalink / raw)
  To: Wei Yongjun; +Cc: mchehab, yongjun_wei, linux-media

On 03/26/2013 07:32 AM, Wei Yongjun wrote:
> From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
>
> Add the missing unlock before return from function af9035_ctrl_msg()
> in the error handling case.
>
> Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>

Acked-by: Antti Palosaari <crope@iki.fi>
Reviewed-by: Antti Palosaari <crope@iki.fi>


> ---
>   drivers/media/usb/dvb-usb-v2/af9035.c | 17 +++++++++--------
>   1 file changed, 9 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c b/drivers/media/usb/dvb-usb-v2/af9035.c
> index b1f7059..b638fc1 100644
> --- a/drivers/media/usb/dvb-usb-v2/af9035.c
> +++ b/drivers/media/usb/dvb-usb-v2/af9035.c
> @@ -57,7 +57,7 @@ static int af9035_ctrl_msg(struct dvb_usb_device *d, struct usb_req *req)
>   		dev_err(&d->udev->dev, "%s: too much data wlen=%d rlen=%d\n",
>   				__func__, req->wlen, req->rlen);
>   		ret = -EINVAL;
> -		goto err;
> +		goto exit;
>   	}
>
>   	state->buf[0] = REQ_HDR_LEN + req->wlen + CHECKSUM_LEN - 1;
> @@ -81,7 +81,7 @@ static int af9035_ctrl_msg(struct dvb_usb_device *d, struct usb_req *req)
>   	ret = dvb_usbv2_generic_rw_locked(d,
>   			state->buf, wlen, state->buf, rlen);
>   	if (ret)
> -		goto err;
> +		goto exit;
>
>   	/* no ack for those packets */
>   	if (req->cmd == CMD_FW_DL)
> @@ -95,28 +95,29 @@ static int af9035_ctrl_msg(struct dvb_usb_device *d, struct usb_req *req)
>   				"(%04x != %04x)\n", KBUILD_MODNAME, req->cmd,
>   				tmp_checksum, checksum);
>   		ret = -EIO;
> -		goto err;
> +		goto exit;
>   	}
>
>   	/* check status */
>   	if (state->buf[2]) {
>   		/* fw returns status 1 when IR code was not received */
> -		if (req->cmd == CMD_IR_GET || state->buf[2] == 1)
> -			return 1;
> +		if (req->cmd == CMD_IR_GET || state->buf[2] == 1) {
> +			ret = 1;
> +			goto exit;
> +		}
>
>   		dev_dbg(&d->udev->dev, "%s: command=%02x failed fw error=%d\n",
>   				__func__, req->cmd, state->buf[2]);
>   		ret = -EIO;
> -		goto err;
> +		goto exit;
>   	}
>
>   	/* read request, copy returned data to return buf */
>   	if (req->rlen)
>   		memcpy(req->rbuf, &state->buf[ACK_HDR_LEN], req->rlen);
>   exit:
> -err:
>   	mutex_unlock(&d->usb_mutex);
> -	if (ret)
> +	if (ret < 0)
>   		dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret);
>   	return ret;
>   }
>
>


-- 
http://palosaari.fi/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH -next] [media] af9035: fix missing unlock on error in af9035_ctrl_msg()
  2013-03-26  9:46 ` Antti Palosaari
@ 2013-03-26 10:00   ` Antti Palosaari
  0 siblings, 0 replies; 3+ messages in thread
From: Antti Palosaari @ 2013-03-26 10:00 UTC (permalink / raw)
  To: mchehab; +Cc: Wei Yongjun, yongjun_wei, linux-media

@Mauro, that bug is new and coming as I rebased AF9035 IR code to the 
new AF9035 non-stacked usb buffers, which introduces that mutex. Just 
apply it to the current master.

regards
Antti



On 03/26/2013 11:46 AM, Antti Palosaari wrote:
> On 03/26/2013 07:32 AM, Wei Yongjun wrote:
>> From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
>>
>> Add the missing unlock before return from function af9035_ctrl_msg()
>> in the error handling case.
>>
>> Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
>
> Acked-by: Antti Palosaari <crope@iki.fi>
> Reviewed-by: Antti Palosaari <crope@iki.fi>
>
>
>> ---
>>   drivers/media/usb/dvb-usb-v2/af9035.c | 17 +++++++++--------
>>   1 file changed, 9 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c
>> b/drivers/media/usb/dvb-usb-v2/af9035.c
>> index b1f7059..b638fc1 100644
>> --- a/drivers/media/usb/dvb-usb-v2/af9035.c
>> +++ b/drivers/media/usb/dvb-usb-v2/af9035.c
>> @@ -57,7 +57,7 @@ static int af9035_ctrl_msg(struct dvb_usb_device *d,
>> struct usb_req *req)
>>           dev_err(&d->udev->dev, "%s: too much data wlen=%d rlen=%d\n",
>>                   __func__, req->wlen, req->rlen);
>>           ret = -EINVAL;
>> -        goto err;
>> +        goto exit;
>>       }
>>
>>       state->buf[0] = REQ_HDR_LEN + req->wlen + CHECKSUM_LEN - 1;
>> @@ -81,7 +81,7 @@ static int af9035_ctrl_msg(struct dvb_usb_device *d,
>> struct usb_req *req)
>>       ret = dvb_usbv2_generic_rw_locked(d,
>>               state->buf, wlen, state->buf, rlen);
>>       if (ret)
>> -        goto err;
>> +        goto exit;
>>
>>       /* no ack for those packets */
>>       if (req->cmd == CMD_FW_DL)
>> @@ -95,28 +95,29 @@ static int af9035_ctrl_msg(struct dvb_usb_device
>> *d, struct usb_req *req)
>>                   "(%04x != %04x)\n", KBUILD_MODNAME, req->cmd,
>>                   tmp_checksum, checksum);
>>           ret = -EIO;
>> -        goto err;
>> +        goto exit;
>>       }
>>
>>       /* check status */
>>       if (state->buf[2]) {
>>           /* fw returns status 1 when IR code was not received */
>> -        if (req->cmd == CMD_IR_GET || state->buf[2] == 1)
>> -            return 1;
>> +        if (req->cmd == CMD_IR_GET || state->buf[2] == 1) {
>> +            ret = 1;
>> +            goto exit;
>> +        }
>>
>>           dev_dbg(&d->udev->dev, "%s: command=%02x failed fw error=%d\n",
>>                   __func__, req->cmd, state->buf[2]);
>>           ret = -EIO;
>> -        goto err;
>> +        goto exit;
>>       }
>>
>>       /* read request, copy returned data to return buf */
>>       if (req->rlen)
>>           memcpy(req->rbuf, &state->buf[ACK_HDR_LEN], req->rlen);
>>   exit:
>> -err:
>>       mutex_unlock(&d->usb_mutex);
>> -    if (ret)
>> +    if (ret < 0)
>>           dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret);
>>       return ret;
>>   }
>>
>>
>
>


-- 
http://palosaari.fi/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-03-26 10:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-26  5:32 [PATCH -next] [media] af9035: fix missing unlock on error in af9035_ctrl_msg() Wei Yongjun
2013-03-26  9:46 ` Antti Palosaari
2013-03-26 10:00   ` Antti Palosaari

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).