All of lore.kernel.org
 help / color / mirror / Atom feed
From: Antti Palosaari <crope@iki.fi>
To: Mauro Carvalho Chehab <m.chehab@samsung.com>
Cc: linux-media@vger.kernel.org
Subject: Re: [PATCH 2/2] af9035: fix broken I2C and USB I/O
Date: Tue, 03 Dec 2013 18:02:33 +0200	[thread overview]
Message-ID: <529E0099.6000408@iki.fi> (raw)
In-Reply-To: <20131203130658.5c80d75b.m.chehab@samsung.com>

On 03.12.2013 17:06, Mauro Carvalho Chehab wrote:
> Em Wed, 27 Nov 2013 22:28:48 +0200
> Antti Palosaari <crope@iki.fi> escreveu:
>
>> There was three small buffer len calculation bugs which caused
>> driver non-working. These are coming from recent commit:
>> commit 7760e148350bf6df95662bc0db3734e9d991cb03
>> [media] af9035: Don't use dynamic static allocation
>>
>> Signed-off-by: Antti Palosaari <crope@iki.fi>
>> ---
>>   drivers/media/usb/dvb-usb-v2/af9035.c | 8 ++++----
>>   1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c b/drivers/media/usb/dvb-usb-v2/af9035.c
>> index c8fcd78..403bf43 100644
>> --- a/drivers/media/usb/dvb-usb-v2/af9035.c
>> +++ b/drivers/media/usb/dvb-usb-v2/af9035.c
>> @@ -131,7 +131,7 @@ static int af9035_wr_regs(struct dvb_usb_device *d, u32 reg, u8 *val, int len)
>>   {
>>   	u8 wbuf[MAX_XFER_SIZE];
>>   	u8 mbox = (reg >> 16) & 0xff;
>> -	struct usb_req req = { CMD_MEM_WR, mbox, sizeof(wbuf), wbuf, 0, NULL };
>> +	struct usb_req req = { CMD_MEM_WR, mbox, 6 + len, wbuf, 0, NULL };
>>
>>   	if (6 + len > sizeof(wbuf)) {
>>   		dev_warn(&d->udev->dev, "%s: i2c wr: len=%d is too big!\n",
>> @@ -238,7 +238,7 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap,
>>   		} else {
>>   			/* I2C */
>>   			u8 buf[MAX_XFER_SIZE];
>> -			struct usb_req req = { CMD_I2C_RD, 0, sizeof(buf),
>> +			struct usb_req req = { CMD_I2C_RD, 0, 5 + msg[0].len,
>
> You should check first if msg[0].len + 5 is not bigger than sizeof(buf).
>
>>   					buf, msg[1].len, msg[1].buf };
>>
>>   			if (5 + msg[0].len > sizeof(buf)) {

Could you explain why? Why it is not enough to check it later as it is 
done in line just top of that text?



>> @@ -274,8 +274,8 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap,
>>   		} else {
>>   			/* I2C */
>>   			u8 buf[MAX_XFER_SIZE];
>> -			struct usb_req req = { CMD_I2C_WR, 0, sizeof(buf), buf,
>> -					0, NULL };
>> +			struct usb_req req = { CMD_I2C_WR, 0, 5 + msg[0].len,
>> +					buf, 0, NULL };
>
> Same here: you should check first if msg[0].len + 5 is not bigger than sizeof(buf).
>
>>
>>   			if (5 + msg[0].len > sizeof(buf)) {
>>   				dev_warn(&d->udev->dev,

Same here. I don't really see your point.

Antti


-- 
http://palosaari.fi/

  reply	other threads:[~2013-12-03 16:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-27 20:28 [PATCH 1/2] af9033: fix broken I2C Antti Palosaari
2013-11-27 20:28 ` [PATCH 2/2] af9035: fix broken I2C and USB I/O Antti Palosaari
2013-12-03 15:06   ` Mauro Carvalho Chehab
2013-12-03 16:02     ` Antti Palosaari [this message]
2013-12-03 15:03 ` [PATCH 1/2] af9033: fix broken I2C Mauro Carvalho Chehab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=529E0099.6000408@iki.fi \
    --to=crope@iki.fi \
    --cc=linux-media@vger.kernel.org \
    --cc=m.chehab@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.