]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
media: dvb-frontends: dib7090p: fix null-ptr-deref in dib7090p_rw_on_apb()
authorAlex Guo <alexguo1023@gmail.com>
Mon, 16 Jun 2025 01:32:31 +0000 (21:32 -0400)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Mon, 16 Jun 2025 11:16:48 +0000 (13:16 +0200)
In dib7090p_rw_on_apb, msg is controlled by user. When msg[0].buf is null and
msg[0].len is zero, former checks on msg[0].buf would be passed. If accessing
msg[0].buf[2] without sanity check, null pointer deref would happen. We add
check on msg[0].len to prevent crash. Similar issue occurs when access
msg[1].buf[0] and msg[1].buf[1].

Similar commit: commit 0ed554fd769a ("media: dvb-usb: az6027: fix null-ptr-deref in az6027_i2c_xfer()")

Signed-off-by: Alex Guo <alexguo1023@gmail.com>
Link: https://lore.kernel.org/r/20250616013231.730221-1-alexguo1023@gmail.com
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/dvb-frontends/dib7000p.c

index 2c2354dd547daa3941f8c9df3cbedc6802f22817..7d3a994b7cc4f0033e43f266f65816468d2e2e68 100644 (file)
@@ -2260,8 +2260,12 @@ static int dib7090p_rw_on_apb(struct i2c_adapter *i2c_adap,
        u16 word;
 
        if (num == 1) {         /* write */
+               if (msg[0].len < 3)
+                       return -EOPNOTSUPP;
                dib7000p_write_word(state, apb_address, ((msg[0].buf[1] << 8) | (msg[0].buf[2])));
        } else {
+               if (msg[1].len < 2)
+                       return -EOPNOTSUPP;
                word = dib7000p_read_word(state, apb_address);
                msg[1].buf[0] = (word >> 8) & 0xff;
                msg[1].buf[1] = (word) & 0xff;