Skip to content

Commit

Permalink
media: dvb-usb-v2: af9035: fix ISO C90 compilation error on af9035_i2…
Browse files Browse the repository at this point in the history
…c_master_xfer

This fixes a 'ISO C90 forbids mixed declarations and code' compilation
error on af9035_i2c_master_xfer, which is caused by the sanity check added
on user controlled msg[i], before declaring the demodulator register.

Fixes: 7bf744f ("media: dvb-usb-v2: af9035: Fix null-ptr-deref in af9035_i2c_master_xfer")
Signed-off-by: Desnes Nunes <desnesn@redhat.com>
Link: https://lore.kernel.org/r/20240919172755.196907-1-desnesn@redhat.com
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
  • Loading branch information
Desnes Nunes authored and Mauro Carvalho Chehab committed Jan 8, 2025
1 parent 94794b5 commit c36b9ad
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions drivers/media/usb/dvb-usb-v2/af9035.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,13 +322,16 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap,
ret = -EOPNOTSUPP;
} else if ((msg[0].addr == state->af9033_i2c_addr[0]) ||
(msg[0].addr == state->af9033_i2c_addr[1])) {
/* demod access via firmware interface */
u32 reg;

if (msg[0].len < 3 || msg[1].len < 1) {
ret = -EOPNOTSUPP;
goto unlock;
}
/* demod access via firmware interface */
u32 reg = msg[0].buf[0] << 16 | msg[0].buf[1] << 8 |
msg[0].buf[2];

reg = msg[0].buf[0] << 16 | msg[0].buf[1] << 8 |
msg[0].buf[2];

if (msg[0].addr == state->af9033_i2c_addr[1])
reg |= 0x100000;
Expand Down Expand Up @@ -385,13 +388,16 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap,
ret = -EOPNOTSUPP;
} else if ((msg[0].addr == state->af9033_i2c_addr[0]) ||
(msg[0].addr == state->af9033_i2c_addr[1])) {
/* demod access via firmware interface */
u32 reg;

if (msg[0].len < 3) {
ret = -EOPNOTSUPP;
goto unlock;
}
/* demod access via firmware interface */
u32 reg = msg[0].buf[0] << 16 | msg[0].buf[1] << 8 |
msg[0].buf[2];

reg = msg[0].buf[0] << 16 | msg[0].buf[1] << 8 |
msg[0].buf[2];

if (msg[0].addr == state->af9033_i2c_addr[1])
reg |= 0x100000;
Expand Down

0 comments on commit c36b9ad

Please sign in to comment.