media: drx: fix a missing check of return value
PATCH 1/1 media: drx: fix a missing check of return value
Function drxj_dap_write_reg16(), which writes data to buffer, may fail. We need to check if it fails, and if so, we should goto error. Otherwise, the buffer will have incorrect data.
--- drivers/media/dvb-frontends/drx39xyj/drxj.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/media/dvb-frontends/drx39xyj/drxj.c +5 -1
@@ -2136,9 +2136,13 @@ int drxj_dap_atomic_read_write_block(struct i2c_device_addr *dev_addr, word = ((u16 ) data[2 * i]); word += (((u16 ) data[(2 * i) +1 ]) <<8 ); -drxj_dap_write_reg16 (dev_addr, + rc =drxj_dap_write_reg16 (dev_addr, (DRXJ_HI_ATOMIC_BUF_START + i), word,0 ); +if (rc) { +pr_err ("error %d\n" , rc); + goto rw_error; + } } }
Signature · 1 line
2.17.2 (Apple Git-113)
Mauro Carvalho Chehab
maintainerEm Thu, 20 Dec 2018 00:57:44 -0600
Kangjie Lu <[email protected]> escreveu:
Quoted 2 lines
Function
drxj_dap_write_reg16(), which writes data to buffer, may fail. We need to check if it fails, and if so, we should goto error.
Did you test this on a real hardware? This kind of patch has a potential of breaking things, as, on some drivers, some writes may return error.
For example, when called on early stages, a write may fail because the firmware was not loaded yet. So, a change like that should be carefully tested with real hardware.
Quoted 16 lines
Otherwise, the buffer will have incorrect data.
Signed-off-by Kangjie Lu <[email protected]>--- drivers/media/dvb-frontends/drx39xyj/drxj.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)drivers/media/dvb-frontends/drx39xyj/drxj.c +0
-1@@ -2136,9 +2136,13 @@ int drxj_dap_atomic_read_write_block(struct i2c_device_addr *dev_addr, word = ((u16 ) data[2 * i]); word += (((u16 ) data[(2 * i) +1 ]) <<8 ); - drxj_dap_write_reg16(dev_addr,
drivers/media/dvb-frontends/drx39xyj/drxj.c int drxj_dap_atomic_read_write_block(struct i2c_device_addr *dev_addr, · line 2148
Quoted 10 lines
drivers/media/dvb-frontends/drx39xyj/drxj.c +5
-0+ rc =drxj_dap_write_reg16 (dev_addr, (DRXJ_HI_ATOMIC_BUF_START + i), word,0 ); +if (rc) { +pr_err ("error %d\n" , rc); + goto rw_error; + } } }
Thanks,
Mauro