* [PATCH] media: drx: fix a missing check of return value
@ 2018-12-20 6:57 Kangjie Lu
2019-01-07 19:22 ` Mauro Carvalho Chehab
0 siblings, 1 reply; 2+ messages in thread
From: Kangjie Lu @ 2018-12-20 6:57 UTC (permalink / raw)
To: kjlu
Cc: pakki001, Mauro Carvalho Chehab, Gustavo A. R. Silva,
linux-media, linux-kernel
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.
Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
drivers/media/dvb-frontends/drx39xyj/drxj.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/media/dvb-frontends/drx39xyj/drxj.c b/drivers/media/dvb-frontends/drx39xyj/drxj.c
index 551b7d65fa66..d105125bc1c3 100644
--- a/drivers/media/dvb-frontends/drx39xyj/drxj.c
+++ b/drivers/media/dvb-frontends/drx39xyj/drxj.c
@@ -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;
+ }
}
}
--
2.17.2 (Apple Git-113)
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] media: drx: fix a missing check of return value
2018-12-20 6:57 [PATCH] media: drx: fix a missing check of return value Kangjie Lu
@ 2019-01-07 19:22 ` Mauro Carvalho Chehab
0 siblings, 0 replies; 2+ messages in thread
From: Mauro Carvalho Chehab @ 2019-01-07 19:22 UTC (permalink / raw)
To: Kangjie Lu; +Cc: pakki001, Gustavo A. R. Silva, linux-media, linux-kernel
Em Thu, 20 Dec 2018 00:57:44 -0600
Kangjie Lu <kjlu@umn.edu> escreveu:
> 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.
> Otherwise, the buffer will have incorrect data.
>
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> ---
> drivers/media/dvb-frontends/drx39xyj/drxj.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/dvb-frontends/drx39xyj/drxj.c b/drivers/media/dvb-frontends/drx39xyj/drxj.c
> index 551b7d65fa66..d105125bc1c3 100644
> --- a/drivers/media/dvb-frontends/drx39xyj/drxj.c
> +++ b/drivers/media/dvb-frontends/drx39xyj/drxj.c
> @@ -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;
> + }
> }
> }
>
Thanks,
Mauro
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-01-07 19:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-20 6:57 [PATCH] media: drx: fix a missing check of return value Kangjie Lu
2019-01-07 19:22 ` 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;
as well as URLs for NNTP newsgroup(s).