Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp788086pxb; Wed, 24 Feb 2021 15:21:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJw26DAYNMN6YTrF02Y9kaTj/4USCDlp7AXws567WQR7aVcIP1Oo94t8ZRTicFegAYqm8Ia+ X-Received: by 2002:a50:9fab:: with SMTP id c40mr211957edf.266.1614208887332; Wed, 24 Feb 2021 15:21:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614208887; cv=none; d=google.com; s=arc-20160816; b=ee/QhTowyi8HIaave1aatoln+M2k+rT4sX/VviDEAxbPEsyY9zJvrUYgLLpNiSQ7CJ 3Pte4dMgUIXVSKIZ6cV6LAtok7lVr0K4loup+fMOXGO2G1yPioH/OTQo/WLvZ+0xENsG srk9lDts1nX55qFr1yY8495jLk6YwX/+y5jSt0gbdoQHDjdntIf5ksn4B/vDZAZUagSB Vnul2A/1tiPFoxdVSK9aeNDl6r0ptf80CKwVO6bg0BJSvdyvaqdbtUzahxBcHz7HCbkX FegM60Kmp6lqRxUi0QtM+XcXafe6jheu52B7qvg+OLY4PEAXBsqHiTQhLcjWBx2beYZV xOOQ== 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=ornvNR42kovWrJY0M/OGE3Df2fJy4by6MWRAZ+9Pe5E=; b=DbU/zNRyqkYuBpd010lwTzQPtQn1mjPJzuBibfAh2lj7VKP6ySFyxR6wI6uLRaTzlj 5t28U3MRv5s8ZBg+YZ1TGVN0gJgu5wJs71QqMHI3dgTb+aJDOqT5Mhx/bT+6aSRTwrzO EJOVhjYYond+pmM76xaU5l07B4WWAa8sIO/NmE3UJa3FmZmV/dBkAMRUmHIC8eRNiWRQ TUOvwJ08e7p1EBogh/GRcAfTf8y8qvBpHi4kO8zWtdpoWOF43wp/6bZW52TLiUOoNPPE GEc69aP/iMnyg9MlYCM4lNhoGhxyw5rf19IKsLEdX0zVNXErpQX8VCJ8A4zL30E8akK8 MB/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OmTsGSrb; 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 v8si2378914ejy.237.2021.02.24.15.21.04; Wed, 24 Feb 2021 15:21:27 -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=OmTsGSrb; 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 S237878AbhBXNtI (ORCPT + 99 others); Wed, 24 Feb 2021 08:49:08 -0500 Received: from mail.kernel.org ([198.145.29.99]:58448 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234888AbhBXNF3 (ORCPT ); Wed, 24 Feb 2021 08:05:29 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2D67464F75; Wed, 24 Feb 2021 12:54:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1614171248; bh=h58OgRccbDxtyFA2G4IeO7kYsX2GyMKKHHc7TnjjtQQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OmTsGSrbbPGKVgYdqQ+VOXeiVnE8DInzTeob1Vh+8sHVDIBn4nJDIkghRg0ZwpcCB QfRmRIo6iSGB80sh330eqOuf2ayr/HFx5ntAk6v1MNAOxompYjtxYphnLAYJhD48NQ mkDI9ZVguWqoLXbGrG+Z+zpyXt/rW8gvjZlRpJVi1sDxv7XG4DKrYP/Nl1iW1dVmru ObCYCekiS6pe++HJmbBwX+TJI2m7oVCcPDbpycUcyiWPZA6z3gQ1zij4Pzh2jI7PW+ SLXXpE97PCpRdMz5qWYuq9J/SfigZ2mgjeH32mfL4ec23NIEWCIFKgi+lWLg5EX+Gt AXMnA6VRWQ1WA== 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 5.4 20/40] media: mceusb: sanity check for prescaler value Date: Wed, 24 Feb 2021 07:53:20 -0500 Message-Id: <20210224125340.483162-20-sashal@kernel.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210224125340.483162-1-sashal@kernel.org> References: <20210224125340.483162-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 f9616158bcf44..ca8995595c028 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; -- 2.27.0