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 X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44B8DC33CAF for ; Thu, 16 Jan 2020 17:54:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 159DE2073A for ; Thu, 16 Jan 2020 17:54:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579197259; bh=eKMbYS1eV6aH1R+JumnZaqRP3Om9A8sq8qmG+cOdrOs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=RuAUy45l9Oq3GU6eZRZ2/E3ErCQFGADIgjj6CeBiH8620HS5NLCLSBZpJ3nHdze0V MM7e6p2tH0jL6ntjA4CL4arDza2fKXeuttvCAU9g9yd4v2LYnX+QN9L/SvWwElbZ18 fY/QytflrlHQm/wwgNcWkMu4eFSl9pMeUWYwO1Ec= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405995AbgAPRox (ORCPT ); Thu, 16 Jan 2020 12:44:53 -0500 Received: from mail.kernel.org ([198.145.29.99]:36062 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732916AbgAPRow (ORCPT ); Thu, 16 Jan 2020 12:44:52 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 587CF24779; Thu, 16 Jan 2020 17:44:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579196692; bh=eKMbYS1eV6aH1R+JumnZaqRP3Om9A8sq8qmG+cOdrOs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nn4KEevzmEqI0YmqH9PAUgVHK+USNt3orWa/T9q5RPgfHcLnbxasWRRBRePRk2132 0dmi8wqhSM/FPgFByVieBlXvjbmKvkg58PMQ1gqjuLzpK3jiVn5O2AepnuMlQIFHU4 mDaDZ5X7I6LHMNTHu2I3/YGUCOcrIGs/Yi0io0nk= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Dan Carpenter , "Lad Prabhakar" , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin , linux-media@vger.kernel.org Subject: [PATCH AUTOSEL 4.4 087/174] media: davinci/vpbe: array underflow in vpbe_enum_outputs() Date: Thu, 16 Jan 2020 12:41:24 -0500 Message-Id: <20200116174251.24326-87-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200116174251.24326-1-sashal@kernel.org> References: <20200116174251.24326-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Dan Carpenter [ Upstream commit b72845ee5577b227131b1fef23f9d9a296621d7b ] In vpbe_enum_outputs() we check if (temp_index >= cfg->num_outputs) but the problem is that "temp_index" can be negative. This patch changes the types to unsigned to address this array underflow bug. Fixes: 66715cdc3224 ("[media] davinci vpbe: VPBE display driver") Signed-off-by: Dan Carpenter Acked-by: "Lad Prabhakar" Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/platform/davinci/vpbe.c | 2 +- include/media/davinci/vpbe.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/davinci/vpbe.c b/drivers/media/platform/davinci/vpbe.c index abce9c4a1a8e..59518c08528b 100644 --- a/drivers/media/platform/davinci/vpbe.c +++ b/drivers/media/platform/davinci/vpbe.c @@ -130,7 +130,7 @@ static int vpbe_enum_outputs(struct vpbe_device *vpbe_dev, struct v4l2_output *output) { struct vpbe_config *cfg = vpbe_dev->cfg; - int temp_index = output->index; + unsigned int temp_index = output->index; if (temp_index >= cfg->num_outputs) return -EINVAL; diff --git a/include/media/davinci/vpbe.h b/include/media/davinci/vpbe.h index 4376beeb28c2..5d8ceeddc797 100644 --- a/include/media/davinci/vpbe.h +++ b/include/media/davinci/vpbe.h @@ -96,7 +96,7 @@ struct vpbe_config { struct encoder_config_info *ext_encoders; /* amplifier information goes here */ struct amp_config_info *amp; - int num_outputs; + unsigned int num_outputs; /* Order is venc outputs followed by LCD and then external encoders */ struct vpbe_output *outputs; }; -- 2.20.1