Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp437114pxb; Wed, 24 Feb 2021 06:17:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJzD8jBprsqk940VsFxfy4LdsMxswj1rSwMvyMamBt1a/U9pwEg4tDhfrOITiVRczn4AiYWY X-Received: by 2002:a17:906:73c2:: with SMTP id n2mr31695921ejl.224.1614176246247; Wed, 24 Feb 2021 06:17:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614176246; cv=none; d=google.com; s=arc-20160816; b=RIr6VvV7TluD3rPF2t3UHYVenc9cKplSqMXYQ9OimlrdlN80AqlhLl4WToBaNXfa3N ryu+ECkJYFv6EVRWIyo5Oo/9Iivch7rRTmMk/FP9qtoCJ3q1IlLOfzBRD+DUwMOOOepx GFv3p9yGU7G+rYVlrKe1jc07P5PNHpMgUjJF2QprkA9KWgGQiYD6e2cnuE92KYv903jI nlCtGlLFHOrl4TosuFvAskUNqwfkKwhXWTe+O8fyeFmkypZnaa0ytBl+1OEuVEmZC2vd xU9xfkFiYIGyoPG1WHbQq8SlmM7F2a2wC3EczcQp6eIUcGR/EDy/iFtIXxBGqDelbor9 lS8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=xJq9tm37ZzjZRP4nsG/K/KVkmGqgxCWSUAD6x229FyM=; b=aAMJGD86Kq2tbqTNVppHkPkvPznRDeOx9Dw51x5VboffklasKvtGM9WsoCR1iozNIZ eoK9lqAEEIeDFGOuKxH+ghbS7mBG12QwbUUjtDDrp0vc0nuDRhTF2PasznP91c6XRj7Q qn1lFA/mblY5RYeiVAGepetIHTEfNeZxTlTQDyZ+vTfEOM8sX66SKgnWnrJMgD5AXHA0 UQBcxmlLs001btHM2sWPfHEOWPBe/NTcLUdyQIvILvccd0k0Oiwz3rBaaIfKk4GLodKz zrPG0Ybn4D1PyGT0LiJLiFxx0L64c0WCXs7Wr9EMWqqaSp2xxwxuo5VjlZjfkwtqnd7O 30Eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OG3Pc1BT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x27si222704ejb.603.2021.02.24.06.16.49; Wed, 24 Feb 2021 06:17:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OG3Pc1BT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235608AbhBXOG2 (ORCPT + 99 others); Wed, 24 Feb 2021 09:06:28 -0500 Received: from mail.kernel.org ([198.145.29.99]:58438 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233607AbhBXNIh (ORCPT ); Wed, 24 Feb 2021 08:08:37 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5B51364F99; Wed, 24 Feb 2021 12:54:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1614171295; bh=WVR7ZEEdctUFWw35chEKS8UARPxWGQ6zEVR3cUJTFnM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OG3Pc1BToATOqRf2KzSMfDnk2iFG09zfuCYtH1M9aDGx2RG6kKLXNx9gAro0oOTt/ UD1DbLZTLmNL4mpC9doxWf5JzFjTnh6//OtnxZyyVKKic7/055Pwn7/IFVONUTjo7G MrAmNjbKGn5yfMwsR+BZSntstjLwcUKSfdCs9uMWbm+c5uRfe6ufFsvoyGjaeMCGzd uvjhYui0cFr75Gy+0+PPCTvKf4sqcKCBaiLxevqM/m4aTJxXtuyBJ36kOvu8FHsd3V JR/h1S0ftaPTCBiYtKPtHrZC/jz6lrAxdAuRRAKMqeet1uCRl4sWxMbj9URIUZETr3 +3bsA88T5rYOA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Sean Young , syzbot+6d31bf169a8265204b8d@syzkaller.appspotmail.com, Mauro Carvalho Chehab , Sasha Levin , linux-media@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 15/26] media: mceusb: sanity check for prescaler value Date: Wed, 24 Feb 2021 07:54:23 -0500 Message-Id: <20210224125435.483539-15-sashal@kernel.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210224125435.483539-1-sashal@kernel.org> References: <20210224125435.483539-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sean Young [ Upstream commit 9dec0f48a75e0dadca498002d25ef4e143e60194 ] 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 Signed-off-by: Sasha Levin --- drivers/media/rc/mceusb.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/media/rc/mceusb.c b/drivers/media/rc/mceusb.c index f1dfb84094328..845583e2af4d5 100644 --- a/drivers/media/rc/mceusb.c +++ b/drivers/media/rc/mceusb.c @@ -685,11 +685,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; -- 2.27.0