Commit b9a92f62 authored by Daniel Scheller's avatar Daniel Scheller Committed by Mauro Carvalho Chehab

media: ddbridge: fix buffer overflow in max_set_input_unlocked()

Picked up code parts introduced one smatch error:

  drivers/media/pci/ddbridge/ddbridge-maxs8.c:163 max_set_input_unlocked() error: buffer overflow 'dev->link[port->lnr].lnb.voltage' 4 <= 255

Fix this by clamping the .lnb.voltage array access to 0-3 by "& 3"'ing
dvb->input.

Cc: Ralph Metzler <rjkm@metzlerbros.de>
Signed-off-by: default avatarDaniel Scheller <d.scheller@gmx.net>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent bb4cec96
...@@ -187,11 +187,12 @@ static int max_set_input_unlocked(struct dvb_frontend *fe, int in) ...@@ -187,11 +187,12 @@ static int max_set_input_unlocked(struct dvb_frontend *fe, int in)
return -EINVAL; return -EINVAL;
if (dvb->input != in) { if (dvb->input != in) {
u32 bit = (1ULL << input->nr); u32 bit = (1ULL << input->nr);
u32 obit = dev->link[port->lnr].lnb.voltage[dvb->input] & bit; u32 obit =
dev->link[port->lnr].lnb.voltage[dvb->input & 3] & bit;
dev->link[port->lnr].lnb.voltage[dvb->input] &= ~bit; dev->link[port->lnr].lnb.voltage[dvb->input & 3] &= ~bit;
dvb->input = in; dvb->input = in;
dev->link[port->lnr].lnb.voltage[dvb->input] |= obit; dev->link[port->lnr].lnb.voltage[dvb->input & 3] |= obit;
} }
res = dvb->set_input(fe, in); res = dvb->set_input(fe, in);
return res; return res;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment