Skip to contentSkip to conversation

media: dvb-usb: az6027: fix null-ptr-deref in az6027_i2c_xfer

PATCH New Alex Guo 1 participant 1 message Jun 21, 2025 Media (V4L/DVB)

lore
Share & tools
lore

Alex Guo

author
#0 lore raw

PATCH 1/1 media: dvb-usb: az6027: fix null-ptr-deref in az6027_i2c_xfer

msg is controlled by user. If accessing msg.buf without sanity check, null pointer deref would happen. Although there are some existing checks on msg.len, they do not cover all buffer access points. Therefore, we add an additional check on msg.len to prevent potential crashes.

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

---
 drivers/media/usb/dvb-usb/az6027.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/usb/dvb-usb/az6027.c +2 -2
index 056935d3cbd6..0c53c8508fc1 100644
@@ -988,7 +988,7 @@ static int az6027_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int n
 			/* write/read request */
 			if (i + 1 < num && (msg[i + 1].flags & I2C_M_RD)) {
 				req = 0xB9;
-				if (msg[i].len < 1) {
+				if (msg[i].len < 2) {
 					i = -EOPNOTSUPP;
 					break;
 				}
@@ -1005,7 +1005,7 @@ static int az6027_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int n
 
 				/* demod 16bit addr */
 				req = 0xBD;
-				if (msg[i].len < 1) {
+				if (msg[i].len < 2) {
 					i = -EOPNOTSUPP;
 					break;
 				}
Signature · 1 line
2.34.1