diff options
author | Patrick Boettcher <pb@linuxtv.org> | 2009-05-20 10:42:33 +0200 |
---|---|---|
committer | Patrick Boettcher <pb@linuxtv.org> | 2009-05-20 10:42:33 +0200 |
commit | 7965383d6db294fc173ab00dd9f407f4af871ef7 (patch) | |
tree | b750dec182721a6225c77cb41a0bb9ec176946f7 /linux/drivers/media/dvb/dvb-usb | |
parent | 6e94aca63322b3d936465135c50d873d53b56c93 (diff) | |
download | mediapointer-dvb-s2-7965383d6db294fc173ab00dd9f407f4af871ef7.tar.gz mediapointer-dvb-s2-7965383d6db294fc173ab00dd9f407f4af871ef7.tar.bz2 |
DIBUSB_MC : fix i2c to not corrupt eeprom in case of strange read pattern
From: matthieu castet <castet.matthieu@free.fr>
dibusb_i2c_xfer seems to do things very dangerous :
it assumes that it get only write/read request or write request.
That means that read can be understood as write. For example a program
doing
file = open("/dev/i2c-x", O_RDWR);
ioctl(file, I2C_SLAVE, 0x50)
read(file, data, 10)
will corrupt the eeprom as it will be understood as a write.
Priority: normal
Signed-off-by: Matthieu CASTET <castet.matthieu@free.fr>
Signed-off-by: Patrick Boettcher <pb@linuxtv.org>
Diffstat (limited to 'linux/drivers/media/dvb/dvb-usb')
-rw-r--r-- | linux/drivers/media/dvb/dvb-usb/dibusb-common.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/linux/drivers/media/dvb/dvb-usb/dibusb-common.c b/linux/drivers/media/dvb/dvb-usb/dibusb-common.c index d774879df..99b3b9a43 100644 --- a/linux/drivers/media/dvb/dvb-usb/dibusb-common.c +++ b/linux/drivers/media/dvb/dvb-usb/dibusb-common.c @@ -133,14 +133,17 @@ static int dibusb_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num for (i = 0; i < num; i++) { /* write/read request */ - if (i+1 < num && (msg[i+1].flags & I2C_M_RD)) { + if (i+1 < num && (msg[i].flags & I2C_M_RD) == 0 + && (msg[i+1].flags & I2C_M_RD)) { if (dibusb_i2c_msg(d, msg[i].addr, msg[i].buf,msg[i].len, msg[i+1].buf,msg[i+1].len) < 0) break; i++; - } else + } else if ((msg[i].flags & I2C_M_RD) == 0) { if (dibusb_i2c_msg(d, msg[i].addr, msg[i].buf,msg[i].len,NULL,0) < 0) break; + } else + break; } mutex_unlock(&d->i2c_mutex); |