From: Sean Young Date: Tue, 19 Jan 2021 13:53:50 +0000 (+0100) Subject: media: mceusb: sanity check for prescaler value X-Git-Tag: v5.15~1736^2~157 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9dec0f48a75e0dadca498002d25ef4e143e60194;p=platform%2Fkernel%2Flinux-starfive.git media: mceusb: sanity check for prescaler value prescaler larger than 8 would mean the carrier is at most 152Hz, which does not make sense for IR carriers. Reported-by: syzbot+6d31bf169a8265204b8d@syzkaller.appspotmail.com Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/rc/mceusb.c b/drivers/media/rc/mceusb.c index c8d6367..5642595 100644 --- a/drivers/media/rc/mceusb.c +++ b/drivers/media/rc/mceusb.c @@ -701,11 +701,18 @@ static void mceusb_dev_printdata(struct mceusb_dev *ir, u8 *buf, int buf_len, data[0], data[1]); break; case MCE_RSP_EQIRCFS: + if (!data[0] && !data[1]) { + dev_dbg(dev, "%s: no carrier", inout); + break; + } + // prescaler should make sense + if (data[0] > 8) + break; period = DIV_ROUND_CLOSEST((1U << data[0] * 2) * (data[1] + 1), 10); if (!period) break; - carrier = (1000 * 1000) / period; + carrier = USEC_PER_SEC / period; dev_dbg(dev, "%s carrier of %u Hz (period %uus)", inout, carrier, period); break;