* [PATCH 1/2] af9033: fix broken I2C @ 2013-11-27 20:28 Antti Palosaari 2013-11-27 20:28 ` [PATCH 2/2] af9035: fix broken I2C and USB I/O Antti Palosaari 2013-12-03 15:03 ` [PATCH 1/2] af9033: fix broken I2C Mauro Carvalho Chehab 0 siblings, 2 replies; 5+ messages in thread From: Antti Palosaari @ 2013-11-27 20:28 UTC (permalink / raw) To: linux-media; +Cc: Antti Palosaari Driver did not work anymore since I2C has gone broken due to recent commit: commit 37ebaf6891ee81687bb558e8375c0712d8264ed8 [media] dvb-frontends: Don't use dynamic static allocation Signed-off-by: Antti Palosaari <crope@iki.fi> --- drivers/media/dvb-frontends/af9033.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/dvb-frontends/af9033.c b/drivers/media/dvb-frontends/af9033.c index 30ee590..08de532 100644 --- a/drivers/media/dvb-frontends/af9033.c +++ b/drivers/media/dvb-frontends/af9033.c @@ -171,7 +171,7 @@ static int af9033_wr_reg_val_tab(struct af9033_state *state, const struct reg_val *tab, int tab_len) { int ret, i, j; - u8 buf[MAX_XFER_SIZE]; + u8 buf[212]; if (tab_len > sizeof(buf)) { dev_warn(&state->i2c->dev, -- 1.8.4.2 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] af9035: fix broken I2C and USB I/O 2013-11-27 20:28 [PATCH 1/2] af9033: fix broken I2C Antti Palosaari @ 2013-11-27 20:28 ` Antti Palosaari 2013-12-03 15:06 ` Mauro Carvalho Chehab 2013-12-03 15:03 ` [PATCH 1/2] af9033: fix broken I2C Mauro Carvalho Chehab 1 sibling, 1 reply; 5+ messages in thread From: Antti Palosaari @ 2013-11-27 20:28 UTC (permalink / raw) To: linux-media; +Cc: Antti Palosaari 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, buf, msg[1].len, msg[1].buf }; if (5 + msg[0].len > sizeof(buf)) { @@ -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 }; if (5 + msg[0].len > sizeof(buf)) { dev_warn(&d->udev->dev, -- 1.8.4.2 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] af9035: fix broken I2C and USB I/O 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 0 siblings, 1 reply; 5+ messages in thread From: Mauro Carvalho Chehab @ 2013-12-03 15:06 UTC (permalink / raw) To: Antti Palosaari; +Cc: linux-media 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)) { > @@ -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, -- Cheers, Mauro ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] af9035: fix broken I2C and USB I/O 2013-12-03 15:06 ` Mauro Carvalho Chehab @ 2013-12-03 16:02 ` Antti Palosaari 0 siblings, 0 replies; 5+ messages in thread From: Antti Palosaari @ 2013-12-03 16:02 UTC (permalink / raw) To: Mauro Carvalho Chehab; +Cc: linux-media 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/ ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] af9033: fix broken I2C 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:03 ` Mauro Carvalho Chehab 1 sibling, 0 replies; 5+ messages in thread From: Mauro Carvalho Chehab @ 2013-12-03 15:03 UTC (permalink / raw) To: Antti Palosaari; +Cc: linux-media Em Wed, 27 Nov 2013 22:28:47 +0200 Antti Palosaari <crope@iki.fi> escreveu: > Driver did not work anymore since I2C has gone broken due > to recent commit: > commit 37ebaf6891ee81687bb558e8375c0712d8264ed8 > [media] dvb-frontends: Don't use dynamic static allocation > > Signed-off-by: Antti Palosaari <crope@iki.fi> > --- > drivers/media/dvb-frontends/af9033.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/media/dvb-frontends/af9033.c b/drivers/media/dvb-frontends/af9033.c > index 30ee590..08de532 100644 > --- a/drivers/media/dvb-frontends/af9033.c > +++ b/drivers/media/dvb-frontends/af9033.c > @@ -171,7 +171,7 @@ static int af9033_wr_reg_val_tab(struct af9033_state *state, > const struct reg_val *tab, int tab_len) > { > int ret, i, j; > - u8 buf[MAX_XFER_SIZE]; > + u8 buf[212]; Please change, instead, the MAX_XFER_SIZE macro. Thanks! Mauro > > if (tab_len > sizeof(buf)) { > dev_warn(&state->i2c->dev, -- Cheers, Mauro ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-12-03 16:02 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 2013-12-03 15:03 ` [PATCH 1/2] af9033: fix broken I2C Mauro Carvalho Chehab
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox