From patchwork Mon Apr 17 12:41:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Elfring X-Patchwork-Id: 13213811 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6B304C77B72 for ; Mon, 17 Apr 2023 12:43:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:References:Cc:To:From: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=94/m7/dOfGvdqze4BrKeH87b4RgiEtF4cZ+SmflWOIM=; b=H/evNN4OB6WvBA PNlmZWpfVZZQDCAKff5mFrr1wXt3mPoczDo61S2I7/ziEyu5SReXqNLtgl8ldtZAW07RMGqR1gAnz PqcHfm2UfCVb8bIVB+fbsCCkZZqM/jLeBiwIOb/GAdZWZKoqUZFIT/YQ/HrwI+aBxBWOR4lD4TfAD IkYywx0hCGWg6k0vc8SzVAQj+WNuNNUfKqfkIjeCgimavM4OUXRTpP93OYt7hYBjBOZRGxtUg95Aw 6BlW86A1GQrsiDg//tADUF6jB2dhYpVNKpCMUHSty8WYisThmzIKMJWZHj650QgfyUy5DO0zC6HHX 03WCBCFGxODegNCDE7YA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1poOBd-00GBAI-0Z; Mon, 17 Apr 2023 12:42:25 +0000 Received: from mout.web.de ([212.227.15.14]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1poOBZ-00GB98-2r; Mon, 17 Apr 2023 12:42:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=s29768273; t=1681735321; i=markus.elfring@web.de; bh=/7c9gMj4NjcLvGOLI8XeYKs0UQMjflGtLvrD94aZldM=; h=X-UI-Sender-Class:Date:Subject:From:To:Cc:References:In-Reply-To; b=Yr6MzbXfXp6dUy1u9zOA1ynxGRukQ6znbHe9Xu38jlkZMWrFPs8tRDJh/MvWx5mIP 9nLOjvAchnSwqS9DRLdu7RZf9j6txlI5FhP8k9zaBUh2cVVkijlgjTPMn5L9pD6lQ4 bPRAixQJutGqTtzwBpm8ZcKsNA89Ucz7N6TQIsuMBPKpvkU/IX7QodF+r+mtCOxjHg FerXX+Vfzc6sLrt+1cA8iO/so4BRGW37s3GLuszDPUnYbFo7eyAfsIhgXLoBF8EB42 68ctrtMoP9ASeDZUL1+k4ynlSMZGOkw5kJ7niZMjEOBT/rnScWZnFD2RA7/ZKZ4KAC m0DmPmrvbNtjg== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from [192.168.178.21] ([94.31.85.83]) by smtp.web.de (mrweb006 [213.165.67.108]) with ESMTPSA (Nemesis) id 1MFayw-1pYNDa3oy6-00HVAa; Mon, 17 Apr 2023 14:42:00 +0200 Message-ID: <12efbbad-cc54-0816-c729-d9e2c81d591d@web.de> Date: Mon, 17 Apr 2023 14:41:57 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: [PATCH 1/2] media: mediatek: vcodec: Delete null pointer checks in vdec_vp9_slice_single_decode() Content-Language: en-GB From: Markus Elfring To: Hans Verkuil , kernel-janitors@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org, Andrew-CT Chen , AngeloGioacchino Del Regno , Ezequiel Garcia , Guo Zhengkui , Haowen Bai , Matthias Brugger , Mauro Carvalho Chehab , Mingjia Zhang , Tiffany Lin , Xiaoyong Lu , Yunfei Dong Cc: cocci@inria.fr, LKML References: <40c60719-4bfe-b1a4-ead7-724b84637f55@web.de> <1a11455f-ab57-dce0-1677-6beb8492a257@web.de> <0341924c-7f0a-28aa-eeae-f7de69ab36d8@xs4all.nl> <1d945069-00d3-7d9e-b783-96c368ff114b@web.de> In-Reply-To: <1d945069-00d3-7d9e-b783-96c368ff114b@web.de> X-Provags-ID: V03:K1:dmpSxqFnjQJG39btpsm/kJMi8zW5CbPNG2lpTaUEWts4Tb1l5n5 j8DBuas0b2aKLCdMHlPQ2hupkb6bMJa45EtyuOq/LUSYnyiy87LEnoHQ5CyBJ9tSGctQOxz VvEge1nQ6mKXNb3HjKiL/r0qjwxRRiWaOtAGOALFMxQDjR9UxTa2QFb3QokMpDdAVd7n+Uj CaplmyzTnzmvAJo4ifPYA== UI-OutboundReport: notjunk:1;M01:P0:Easlr+g+S+E=;dHeKA2+2cVRkKDVnkADABh4UljX OnDwg80UsQK6yGs6txcyAnJMy0jlbSqmhXzJB8eHxNzpPuaPFFmoOwh1KyK/Qx+jUK/ctUr9e FTiCJm5dHw4JgX2KpEEROgom8M6vKcfLcsGb+U+XAgTHNctyzpHBLswx+WJLpitCK9qHMX9TQ fGPsppc4/TWkNr2SsU/UMbo0V92Q8inaTD5OngjfXFaaiRqrlhUOj0DTe9ptMGi9uqzSyETXS BiIsOfwdcC3Ym8Rw10wK2m3u2cus65xkTUUC61JHeZ8llN9j/yxoLCbcrNtdQNEuaoIfJ2cVW 5XiyyKgAU3V6NfjovRsyK5aDn5yKQBQ61LEc6hFvLOvot/H4ocHXP9xwb4MHnC0m3ZQZg/TO4 w3w41y1FuODY79hjubw08GrIf5qYrrgxKwqFtri10O6kCo4/M85toriF8kFcr8f90PegVYFOE OB+RfnqGj6TpWn3NwJc6wHj4OJJeP8TfGH1l9s6/Z0BdPIHJetNY2UOgx3lSgVcF8nkyFq6r0 /Lz3EH2Esr5wEGyx7cErGLGH8HTxSuNWdU/7Fpi3ew+o/olKfvSqs2Mol2df2+NPPWb1N75pO LA/gaOOTZKG4QSNE4Zbyl+pWH82CqYDqPnKE+yzHfznvTpxObkPciaoae+TsO6dYhx339+5u3 c+dI8LKJvJE6gI+5O10KccJTaYISUAIY8mBnYQqxie8C94y0RQK42o9b7sjlToHjVHXziCJxz hcOzlPDDEE+ZNVICKZH4IlmDrMjsKECoFY6MWs6Q6KJ7r1wISaBdEds2dB4SJ0qqqjsyw6RzC BKYiydO1Oo8McfeFZ6kc4DLCkrh94WuMO9B0fNQTg12vVzrZtzuHYegLJaLGBe3hhCUi6y/s/ teDfBz15//6hj6Drda9DdNGtZOS1zsDg90fEUPcSkxpQcBT3SX3i/UVeh X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230417_054222_205712_63FAEBB5 X-CRM114-Status: UNSURE ( 8.32 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Date: Mon, 17 Apr 2023 13:43:31 +0200 Extra null pointer checks became unwanted for the input parameter validation in the implementation of the function “vdec_vp9_slice_single_decode”. Thus omit an if statement at the beginning. Link: https://lore.kernel.org/kernel-janitors/0341924c-7f0a-28aa-eeae-f7de69ab36d8@xs4all.nl/ Signed-off-by: Markus Elfring --- .../media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c | 2 -- 1 file changed, 2 deletions(-) -- 2.40.0 diff --git a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c index cf16cf2807f0..8430098ed0b1 100644 --- a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c +++ b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c @@ -1995,8 +1995,6 @@ static int vdec_vp9_slice_single_decode(void *h_vdec, struct mtk_vcodec_mem *bs, struct mtk_vcodec_ctx *ctx; int ret; - if (!instance || !instance->ctx) - return -EINVAL; ctx = instance->ctx; /* bs NULL means flush decoder */ From patchwork Mon Apr 17 12:44:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Elfring X-Patchwork-Id: 13213821 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 91C5EC77B70 for ; Mon, 17 Apr 2023 12:45:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:References:Cc:To:From: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=fpZQyWXZv1SGvHMAsf/C6+mgHGstYIKKvbsIaTp56kg=; b=YXQEDszzQSifzx iPettplb3bAFSEvEmgDrgY4tzEJvtUqbu5Ph+pCFHUdp1FLKilNCvCq3qhGmJAYrdBCDLEgjbIBGO auJb1Teu2qNZroxBhqhDXcbIK3sfJBu9ZniWKo2ppvszNYK/oPFk55f3pzwwLy7InY0/UBurasUgd kVBRaRkkr5ykdJmJMJ80FgBoR9QWcvHqzxIkRxtsDy0zCkxt2Fxk57O6WB2GdOJXN9ZlENu1ncNfu JeHFFFfsJMtorFfJof+0TJCSWTEH9+c1Fh6imOxHevLxGe7evKjc7I1u8jj6eVWcFGV6cmRwWBApv p3P0nlt5IOQ0XNs25oeQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1poODn-00GBji-0c; Mon, 17 Apr 2023 12:44:39 +0000 Received: from mout.web.de ([212.227.15.3]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1poODj-00GBiC-32; Mon, 17 Apr 2023 12:44:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=s29768273; t=1681735456; i=markus.elfring@web.de; bh=qDbD7coCJdS/2vghLIEPg9MEuMfbhlibiv4/QKu/6Ko=; h=X-UI-Sender-Class:Date:Subject:From:To:Cc:References:In-Reply-To; b=KEjOgP7eoC1d5PY6UHjH1inXCHIIDZLUn/kLNZRyKkntwWD2tiVRU60xuD2DIpdOV yY5871reCDzSeViBoG7BQ+JOSZC6HgiYTOGfy54QUF3fztBcQAJ/mSsG+5QK8XgL5m tdAT7alHVL99YMva8SIOzkxgo5qVGYGZmXm8zdDyX5MT3mdCy450IcfMQxLlBZ6su9 PkJb8o8tKK9d5E0f9pLnlyFt3g+CAjGdb3KcvVpOzlqdWit+AacQoq1OGX7K1sv5X4 csF/On+W6fvLyD8p20o9+0AADmvIV/UVK9qehvLbimc7cM5FjX5Bl16BpcUSLbf5BM e0sjeD/2hKugA== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from [192.168.178.21] ([94.31.85.83]) by smtp.web.de (mrweb005 [213.165.67.108]) with ESMTPSA (Nemesis) id 1MPrPT-1q1ucW3HwR-00Mp6E; Mon, 17 Apr 2023 14:44:15 +0200 Message-ID: <4a357fbe-4f9d-37d1-0be1-93ca754698e9@web.de> Date: Mon, 17 Apr 2023 14:44:14 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: [PATCH 2/2] media: mediatek: vcodec: Move variable assignments behind null pointer checks in vdec_vp9_slice_single_decode() Content-Language: en-GB From: Markus Elfring To: Hans Verkuil , kernel-janitors@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org, Andrew-CT Chen , AngeloGioacchino Del Regno , Ezequiel Garcia , Guo Zhengkui , Haowen Bai , Matthias Brugger , Mauro Carvalho Chehab , Mingjia Zhang , Tiffany Lin , Xiaoyong Lu , Yunfei Dong Cc: cocci@inria.fr, LKML References: <40c60719-4bfe-b1a4-ead7-724b84637f55@web.de> <1a11455f-ab57-dce0-1677-6beb8492a257@web.de> <0341924c-7f0a-28aa-eeae-f7de69ab36d8@xs4all.nl> <1d945069-00d3-7d9e-b783-96c368ff114b@web.de> In-Reply-To: <1d945069-00d3-7d9e-b783-96c368ff114b@web.de> X-Provags-ID: V03:K1:6QuD1QlYQUklTPHI55F/pOJ74eoA08cFgoFR3pUXzqg7KkqkCGb vfSW0TZWJeguxYecDytyW8/z9+6AUkN6oXtchooluTt+S62j3IV+JyC86VDiFE65xtZa2Gh /68nhN6TfWRwWLTxgyzzmYPFt8D9Xlpyz2VTQlorBP/oo9rMUQTkqlkDuQ+26YtK0P6839A A1eAkYZIagDBFkTfXKAQA== UI-OutboundReport: notjunk:1;M01:P0:CWNCASpe+a4=;1DRkwAqrwvRiACXmvTDeqvXjEmi oqdABA8YJZc/XMyY9mcjY4XPxroiRBLH/w3MpNK1GXPH8Sp/x/rSGZahYZm7U7Ry5c6d2YpYw GLC4ixDQ1QLfWFvzW6OtTHRmE/Dg5VjbocNbkIvuYprq50ytv7PlzMm07j7CrBMRtK9DQ9gAi T5Y4B1k5BHfTihy7o2w6NvdAIAe3nxOwBnR5aUgQjEWLFubluPSthoM4bvO1WLaaLzNKyJN5+ Opg3KtWSABK5gvA35jorZ1SVmjXrlLn9pFJuEFmOQL20xydpD6wZlVXrKiOlJvR59+Nv/k949 FhUtFYk6ij26La5xnOtnmLufrFWedksMGmOWDnmcoERfxvV4ObCaxm6Rx1huSnKTskEecso2G aNARatVRcVXOoIu15lSHBNF6pxAkctxLcbJzkkTL4Gb8vW30KVZ7eYM2Mi72E8IrTAdfQcgYC YohrIDyOvpYvkYbYj8Q3wF4pOrfb4QUDxAzICihFVXFQGo0CPoaAcRdaiJfo6SAf/KEhEd3Wr xsTaLG47SyU8PbszIs2cFP8kPJsZAuvuk/ZNimp3yIWgNLcXi7ifM/kkFYHZ29M1RyPf2YKm/ K9TI71NA/iOFeGwPM+FL3Odn7EAUvsNj4bU1JgyHhhsbiazpT2NlqbAaxG3LDpYCRwF4PWXjo kk8naRv50fhphndGuElqL+ueTy56Fyw2xvkNnUXAMxhmkF879Bbey8JowItOV2B0ImhHqF4YO 4Y1Bc0ANxy2d5q3Oewcr3+VSgM6h4msR4ayU+4jF8v1QbOxtBsrm4Rf7XHOsjOfSgB4pGtfkJ W4fFeUbInMnkj/H/YOVLxHvLW1rDW5ph8K4aTzZJcFyAWzrMNGuack9PIFNMW7KBAun9ZlxeJ lJ0eDPbY0nKn07JGThVfwaCKRewgIGmRh5F5gUESYo6rquJ0jhkT2o7xnimnS1U70JSWPYO08 ooWviw== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230417_054436_271076_857705A6 X-CRM114-Status: UNSURE ( 9.66 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Date: Mon, 17 Apr 2023 14:19:13 +0200 The addresses which were assigned to the variables “instance”, “pfc” and “ctx” would not be used if a null pointer was passed by the input parameter “bs”. Thus move these assignments behind corresponding pointer checks. Signed-off-by: Markus Elfring --- .../platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) -- 2.40.0 diff --git a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c index 8430098ed0b1..562fe07d3731 100644 --- a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c +++ b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c @@ -1989,22 +1989,23 @@ static int vdec_vp9_slice_get_param(void *h_vdec, enum vdec_get_param_type type, static int vdec_vp9_slice_single_decode(void *h_vdec, struct mtk_vcodec_mem *bs, struct vdec_fb *fb, bool *res_chg) { - struct vdec_vp9_slice_instance *instance = h_vdec; - struct vdec_vp9_slice_pfc *pfc = &instance->sc_pfc; + struct vdec_vp9_slice_instance *instance; + struct vdec_vp9_slice_pfc *pfc; struct vdec_vp9_slice_vsi *vsi; struct mtk_vcodec_ctx *ctx; int ret; - ctx = instance->ctx; - /* bs NULL means flush decoder */ if (!bs) return vdec_vp9_slice_flush(h_vdec, bs, fb, res_chg); + instance = h_vdec; + ctx = instance->ctx; fb = ctx->dev->vdec_pdata->get_cap_buffer(ctx); if (!fb) return -EBUSY; + pfc = &instance->sc_pfc; vsi = &pfc->vsi; ret = vdec_vp9_slice_setup_single(instance, bs, fb, pfc);