From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3286EC433FE for ; Tue, 1 Nov 2022 11:38:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230027AbiKALin (ORCPT ); Tue, 1 Nov 2022 07:38:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231379AbiKALiV (ORCPT ); Tue, 1 Nov 2022 07:38:21 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93C0B1DF05; Tue, 1 Nov 2022 04:32:30 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B3BF8615FC; Tue, 1 Nov 2022 11:31:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 580CCC433D6; Tue, 1 Nov 2022 11:31:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667302284; bh=UCC8lyDEoZajJOcyBilNX3fzGYsshdVzFMcs3OEstNw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cazFgmPSyS/y4hdw9scYB7cDm91AKNw2xgptGQHNnyc7WJNXlr1ZlX9/Kvhp861xm IDQGGsSs7FtG1D4vLoLMy2A8xz9gRfp7Ie351erqQ/tyS7l3FSr9XMSO1UZsA+pfHL XphFP52DOYoaTZLcWf9hFqqsfrkpDuIcpuTmNMYYNiTacQrpbkROcXNaiiFdTJr8if 8THJhyvDf3FdkjTbQbEZUF5Hw0YVFTLMH6yioz7ZETxh0+ems9+dwLtWnjzEChW6ZJ nMtGzE+wlOt2yIUUJQpjX6ZrjPK/hzOnm88LUP9Dky2skfbinOdLCsdHuyHPyporLg W1VU5ejTsLswA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin , bleung@chromium.org, linux-media@vger.kernel.org, chrome-platform@lists.linux.dev Subject: [PATCH AUTOSEL 4.19 2/6] media: cros-ec-cec: limit msg.len to CEC_MAX_MSG_SIZE Date: Tue, 1 Nov 2022 07:31:12 -0400 Message-Id: <20221101113118.800889-2-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221101113118.800889-1-sashal@kernel.org> References: <20221101113118.800889-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: Hans Verkuil [ Upstream commit 2dc73b48665411a08c4e5f0f823dea8510761603 ] I expect that the hardware will have limited this to 16, but just in case it hasn't, check for this corner case. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/platform/cros-ec-cec/cros-ec-cec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/media/platform/cros-ec-cec/cros-ec-cec.c b/drivers/media/platform/cros-ec-cec/cros-ec-cec.c index 7bc4d8a9af28..1f35770245d1 100644 --- a/drivers/media/platform/cros-ec-cec/cros-ec-cec.c +++ b/drivers/media/platform/cros-ec-cec/cros-ec-cec.c @@ -44,6 +44,8 @@ static void handle_cec_message(struct cros_ec_cec *cros_ec_cec) uint8_t *cec_message = cros_ec->event_data.data.cec_message; unsigned int len = cros_ec->event_size; + if (len > CEC_MAX_MSG_SIZE) + len = CEC_MAX_MSG_SIZE; cros_ec_cec->rx_msg.len = len; memcpy(cros_ec_cec->rx_msg.msg, cec_message, len); -- 2.35.1