From patchwork Tue Nov 3 20:34:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 316862 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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 A480BC2D0A3 for ; Tue, 3 Nov 2020 21:44:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5B34F2236F for ; Tue, 3 Nov 2020 21:44:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604439843; bh=VUeq2k+hGnGaqdS/JS60ttsAYkd4Jg1emjn69elzK4Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=cBJH8YtlFbYC+Llr895USWqwtmqkij/AtTIk1V4dfBLNeJR3wCEtd02UOMWBmQvFB WPuqoSBKQNtSuRLSeGVqCHxaexwxefHKC7GytToHTcUFMV1jg9XRsXr+sNXjBU1dgj btQT0KNc9i3U5lSrpxrHTrRvrAglTXADvuhjNf/M= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732100AbgKCVoB (ORCPT ); Tue, 3 Nov 2020 16:44:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:53176 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732549AbgKCUyP (ORCPT ); Tue, 3 Nov 2020 15:54:15 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DC9412053B; Tue, 3 Nov 2020 20:54:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604436855; bh=VUeq2k+hGnGaqdS/JS60ttsAYkd4Jg1emjn69elzK4Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CxfstxiFM3u4JzKhh8XgGrgFL8nmoBf+jiqJXeGS0Zqjh3iWNfMtvI5NqxqdlnWCS bRLIC9cYvZJgURsYFGvo6+8qm/musCEk7SYkfVZqL4dT4EEDF6QbH4m2KXYzA33WfB v8un+ROECWzLkzF22eK9ryPdbpOLetd+oqYJ+qW0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tomasz Figa , Xia Jiang , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.4 041/214] media: platform: Improve queue set up flow for bug fixing Date: Tue, 3 Nov 2020 21:34:49 +0100 Message-Id: <20201103203253.942345574@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203249.448706377@linuxfoundation.org> References: <20201103203249.448706377@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Xia Jiang [ Upstream commit 5095a6413a0cf896ab468009b6142cb0fe617e66 ] Add checking created buffer size follow in mtk_jpeg_queue_setup(). Reviewed-by: Tomasz Figa Signed-off-by: Xia Jiang Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c b/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c index ee802fc3bcdfc..9fa1bc5514f3e 100644 --- a/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c +++ b/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c @@ -571,6 +571,13 @@ static int mtk_jpeg_queue_setup(struct vb2_queue *q, if (!q_data) return -EINVAL; + if (*num_planes) { + for (i = 0; i < *num_planes; i++) + if (sizes[i] < q_data->sizeimage[i]) + return -EINVAL; + return 0; + } + *num_planes = q_data->fmt->colplanes; for (i = 0; i < q_data->fmt->colplanes; i++) { sizes[i] = q_data->sizeimage[i];