af9013: Don't accept invalid bandwidth
authorMauro Carvalho Chehab <mchehab@osg.samsung.com>
Tue, 28 Apr 2015 22:02:19 +0000 (19:02 -0300)
committerDanny Wood <danwood76@gmail.com>
Tue, 29 Jan 2019 13:09:15 +0000 (13:09 +0000)
commit d7b76c91f471413de9ded837bddeca2164786571 upstream.

If userspace sends an invalid bandwidth, it should either return
EINVAL or switch to auto mode.

This driver will go past an array and program the hardware on a
wrong way if this happens.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/media/dvb-frontends/af9013.c

index fb504f1e912500c3f8c04a9e1e0f0472255597a6..5930aee6b5d0597facf0c17b88c6859fdc01c43a 100644 (file)
@@ -606,6 +606,10 @@ static int af9013_set_frontend(struct dvb_frontend *fe)
                        }
                }
 
+               /* Return an error if can't find bandwidth or the right clock */
+               if (i == ARRAY_SIZE(coeff_lut))
+                       return -EINVAL;
+
                ret = af9013_wr_regs(state, 0xae00, coeff_lut[i].val,
                        sizeof(coeff_lut[i].val));
        }