kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil-cisco@xs4all.nl>
To: Markus Elfring <Markus.Elfring@web.de>,
	kernel-janitors@vger.kernel.org,
	linux-mediatek@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org,
	linux-media@vger.kernel.org,
	Andrew-CT Chen <andrew-ct.chen@mediatek.com>,
	AngeloGioacchino Del Regno 
	<angelogioacchino.delregno@collabora.com>,
	Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>,
	Guo Zhengkui <guozhengkui@vivo.com>,
	Haowen Bai <baihaowen@meizu.com>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Mingjia Zhang <mingjia.zhang@mediatek.com>,
	Tiffany Lin <tiffany.lin@mediatek.com>,
	Xiaoyong Lu <xiaoyong.lu@mediatek.com>,
	Yunfei Dong <yunfei.dong@mediatek.com>
Cc: cocci@inria.fr, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] media: mediatek: vcodec: Move a variable assignment behind condition checks in vdec_vp9_slice_single_decode()
Date: Mon, 17 Apr 2023 10:01:29 +0200	[thread overview]
Message-ID: <0341924c-7f0a-28aa-eeae-f7de69ab36d8@xs4all.nl> (raw)
In-Reply-To: <b98dcc94-13f3-a6cb-f5bd-f1f8644d87d1@web.de>

On 14/04/2023 20:30, Markus Elfring wrote:
> Date: Fri, 14 Apr 2023 20:07:01 +0200
> 
> The address of a data structure member was determined before
> a corresponding null pointer check in the implementation of
> the function “vdec_vp9_slice_single_decode”.
> 
> Thus avoid the risk for undefined behaviour by moving the assignment
> for the variable “pfc” behind some condition checks.
> 
> This issue was detected by using the Coccinelle software.
> 
> Fixes: b0f407c19648ae9110c932c91d6e1b9381ec0aeb ("media: mediatek: vcodec: add vp9 decoder driver for mt8186")

Not a fix, it was never broken.

> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  .../media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c  | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> 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..22b27f7b57bf 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
> @@ -1990,7 +1990,7 @@ 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;

Just drop these lines instead:

        if (!instance || !instance->ctx)
                return -EINVAL;

That can never happen.

Regards,

	Hans

> -	struct vdec_vp9_slice_pfc *pfc = &instance->sc_pfc;
> +	struct vdec_vp9_slice_pfc *pfc;
>  	struct vdec_vp9_slice_vsi *vsi;
>  	struct mtk_vcodec_ctx *ctx;
>  	int ret;
> @@ -2007,6 +2007,7 @@ static int vdec_vp9_slice_single_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
>  	if (!fb)
>  		return -EBUSY;
> 
> +	pfc = &instance->sc_pfc;
>  	vsi = &pfc->vsi;
> 
>  	ret = vdec_vp9_slice_setup_single(instance, bs, fb, pfc);
> --
> 2.40.0
> 


  parent reply	other threads:[~2023-04-17  8:02 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <40c60719-4bfe-b1a4-ead7-724b84637f55@web.de>
     [not found] ` <1a11455f-ab57-dce0-1677-6beb8492a257@web.de>
2023-04-09 18:45   ` [cocci] Reconsidering pointer dereferences before null pointer checks (with SmPL) Julia Lawall
     [not found]     ` <95caa4c1-2455-2733-ef4b-3ab07783c725@web.de>
2023-04-10  6:25       ` Julia Lawall
     [not found]         ` <2de88997-0732-d0dd-5178-f9d42b5a3be5@web.de>
2023-04-10  8:00           ` Julia Lawall
     [not found]             ` <31b51efc-afbe-ec34-255e-9df60983ec3d@web.de>
     [not found]               ` <alpine.DEB.2.22.394.2304101415040.2875@hadrien>
     [not found]                 ` <5defca25-d893-f61a-ec24-aa99ba39d8a7@web.de>
2023-04-11  7:40                   ` Julia Lawall
2023-04-11  9:47                     ` Dan Carpenter
     [not found]   ` <13566308-9a80-e4aa-f64e-978c02b1406d@web.de>
2023-04-11 16:43     ` [PATCH] drm/msm/dpu: Delete a variable initialisation before a null pointer check in two functions Dmitry Baryshkov
2023-04-11 16:44     ` Abhinav Kumar
     [not found]   ` <54a21fea-64e3-de67-82ef-d61b90ffad05@web.de>
2023-04-13 15:49     ` [PATCH] perf map: Delete two variable initialisations before null pointer checks in sort__sym_from_cmp() Ian Rogers
     [not found]   ` <d8ed4e5d-49d4-ca7e-1283-1ec166bf643d@web.de>
2023-04-14 17:13     ` [PATCH] media: atomisp: Move a variable assignment behind a null pointer check in atomisp_cp_general_isp_parameters() Andy Shevchenko
2023-04-16 13:12       ` Hans de Goede
     [not found]   ` <d2403b7a-c6cd-4ee9-2a35-86ea57554eec@web.de>
2023-04-14 15:22     ` [PATCH] nvdimm: Replace the usage of a variable by a direct function call in nd_pfn_validate() Alison Schofield
     [not found]       ` <88f4dd20-4159-2b66-3adc-9a5a68f9eec7@web.de>
2023-04-14 19:14         ` Alison Schofield
2023-04-14 17:15     ` Andy Shevchenko
     [not found]   ` <b98dcc94-13f3-a6cb-f5bd-f1f8644d87d1@web.de>
2023-04-17  7:44     ` [PATCH] media: mediatek: vcodec: Move a variable assignment behind condition checks in vdec_vp9_slice_single_decode() AngeloGioacchino Del Regno
2023-04-17  8:01     ` Hans Verkuil [this message]
     [not found]   ` <622ed461-059b-455f-8a7b-7200a834bdc4@web.de>
2023-04-17  7:58     ` [PATCH] media: au0828: Move a variable assignment behind condition checks in au0828_isoc_copy() Hans Verkuil
     [not found]   ` <2a746461-844a-2ad6-7b52-03f13fe1b9bf@web.de>
2023-04-17 16:25     ` [PATCH 0/9] GPU-DRM-nouveau: Adjustments for seven function implementations Karol Herbst
     [not found]   ` <5800e1f5-8681-e140-fef0-8b2c3b4b6efa@web.de>
2023-04-18 12:51     ` [PATCH] gfs2: Move a variable assignment behind a null pointer check in inode_go_dump() Andreas Gruenbacher
     [not found]   ` <c18331ca-3de9-d433-f477-b04103958b9c@web.de>
2023-04-19 19:03     ` [PATCH] ASoC: SOF: Intel: hda-stream: Move three variable assignments behind condition checks in hda_dsp_iccmax_stream_hw_params() Pierre-Louis Bossart
     [not found]   ` <10e10996-d53d-0733-6d90-a04f251812ba@web.de>
2023-04-21  5:09     ` [PATCH] usb: dwc2: gadget: Move a variable assignment behind condition checks in dwc2_hsotg_handle_outdone() Minas Harutyunyan
     [not found]   ` <93913f0c-4699-cf9a-0f10-8edd478fd2b3@web.de>
2023-04-21  5:32     ` [PATCH 0/4] staging: rtl8712: Adjustments for process_link_qual() Philipp Hortmann
     [not found]   ` <14636275-4d26-d639-5f6e-293fc6d1c4c6@web.de>
2023-04-25 13:30     ` [PATCH] drm/bridge: it6505: Move a variable assignment behind a null pointer check in receive_timing_debugfs_show() Robert Foss
     [not found]       ` <6f758653-36c9-91a2-7bbc-278ae3f8ccee@web.de>
2023-04-27 15:10         ` Robert Foss
     [not found]           ` <14083012-2f19-3760-a840-d685fcedc15e@web.de>
2023-04-28 11:49             ` Robert Foss
     [not found]               ` <fa69384f-1485-142b-c4ee-3df54ac68a89@web.de>
2023-04-28 17:27                 ` [PATCH resent] " Robert Foss
     [not found]   ` <2258ce64-2a14-6778-8319-b342b06a1f33@web.de>
     [not found]     ` <0d4b92ab-f7c2-4f18-f3c3-c0f82ba47fc8@web.de>
2023-04-11 13:59       ` [PATCH 1/5] drm/amdgpu: Move a variable assignment behind a null pointer check in amdgpu_ras_interrupt_dispatch() Felix Kuehling
     [not found]     ` <89048a5f-2dbb-012c-41f5-7c300e8415f5@web.de>
2023-04-11 15:04       ` [PATCH 2/5] drm/amd/display: Move three variable assignments behind condition checks in trigger_hotplug() Christian König
2024-01-05 19:21     ` [PATCH 0/5] drm/amd: Adjustments for three function implementations Markus Elfring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0341924c-7f0a-28aa-eeae-f7de69ab36d8@xs4all.nl \
    --to=hverkuil-cisco@xs4all.nl \
    --cc=Markus.Elfring@web.de \
    --cc=andrew-ct.chen@mediatek.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=baihaowen@meizu.com \
    --cc=cocci@inria.fr \
    --cc=ezequiel@vanguardiasur.com.ar \
    --cc=guozhengkui@vivo.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=mchehab@kernel.org \
    --cc=mingjia.zhang@mediatek.com \
    --cc=tiffany.lin@mediatek.com \
    --cc=xiaoyong.lu@mediatek.com \
    --cc=yunfei.dong@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).