Skip to content

Commit c36b9ad

Browse files
Desnes Nunesmchehab
authored andcommitted
media: dvb-usb-v2: af9035: fix ISO C90 compilation error on af9035_i2c_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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent 94794b5 commit c36b9ad

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

drivers/media/usb/dvb-usb-v2/af9035.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -322,13 +322,16 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap,
322322
ret = -EOPNOTSUPP;
323323
} else if ((msg[0].addr == state->af9033_i2c_addr[0]) ||
324324
(msg[0].addr == state->af9033_i2c_addr[1])) {
325+
/* demod access via firmware interface */
326+
u32 reg;
327+
325328
if (msg[0].len < 3 || msg[1].len < 1) {
326329
ret = -EOPNOTSUPP;
327330
goto unlock;
328331
}
329-
/* demod access via firmware interface */
330-
u32 reg = msg[0].buf[0] << 16 | msg[0].buf[1] << 8 |
331-
msg[0].buf[2];
332+
333+
reg = msg[0].buf[0] << 16 | msg[0].buf[1] << 8 |
334+
msg[0].buf[2];
332335

333336
if (msg[0].addr == state->af9033_i2c_addr[1])
334337
reg |= 0x100000;
@@ -385,13 +388,16 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap,
385388
ret = -EOPNOTSUPP;
386389
} else if ((msg[0].addr == state->af9033_i2c_addr[0]) ||
387390
(msg[0].addr == state->af9033_i2c_addr[1])) {
391+
/* demod access via firmware interface */
392+
u32 reg;
393+
388394
if (msg[0].len < 3) {
389395
ret = -EOPNOTSUPP;
390396
goto unlock;
391397
}
392-
/* demod access via firmware interface */
393-
u32 reg = msg[0].buf[0] << 16 | msg[0].buf[1] << 8 |
394-
msg[0].buf[2];
398+
399+
reg = msg[0].buf[0] << 16 | msg[0].buf[1] << 8 |
400+
msg[0].buf[2];
395401

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

0 commit comments

Comments
 (0)