public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: andrew-ct.chen@mediatek.com (andrew-ct chen)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] [media] VPU: mediatek: fix dereference of pdev before checking it is null
Date: Mon, 21 Nov 2016 19:16:29 +0800	[thread overview]
Message-ID: <1479726989.25126.2.camel@mtksdaap41> (raw)
In-Reply-To: <20161116191650.11486-1-colin.king@canonical.com>

On Wed, 2016-11-16 at 19:16 +0000, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> pdev is dereferenced using platform_get_drvdata before a check to
> see if it is null, hence there could be a potential null pointer
> dereference issue. Instead, first check if pdev is null and only then
> deference pdev when initializing vpu.
> 
> Found with static analysis by CoverityScan, CID 1357797
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---

Reviewed-by: Andrew-CT Chen <andrew-ct.chen@mediatek.com>

>  drivers/media/platform/mtk-vpu/mtk_vpu.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/platform/mtk-vpu/mtk_vpu.c b/drivers/media/platform/mtk-vpu/mtk_vpu.c
> index c9bf58c..41f31b2 100644
> --- a/drivers/media/platform/mtk-vpu/mtk_vpu.c
> +++ b/drivers/media/platform/mtk-vpu/mtk_vpu.c
> @@ -523,9 +523,9 @@ static int load_requested_vpu(struct mtk_vpu *vpu,
>  
>  int vpu_load_firmware(struct platform_device *pdev)
>  {
> -	struct mtk_vpu *vpu = platform_get_drvdata(pdev);
> +	struct mtk_vpu *vpu;
>  	struct device *dev = &pdev->dev;
> -	struct vpu_run *run = &vpu->run;
> +	struct vpu_run *run;
>  	const struct firmware *vpu_fw = NULL;
>  	int ret;
>  
> @@ -533,6 +533,8 @@ int vpu_load_firmware(struct platform_device *pdev)
>  		dev_err(dev, "VPU platform device is invalid\n");
>  		return -EINVAL;
>  	}
> +	vpu = platform_get_drvdata(pdev);
> +	run = &vpu->run;
>  
>  	mutex_lock(&vpu->vpu_mutex);
>  	if (vpu->fw_loaded) {

      parent reply	other threads:[~2016-11-21 11:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-16 19:16 [PATCH] [media] VPU: mediatek: fix dereference of pdev before checking it is null Colin King
2016-11-18  9:49 ` Matthias Brugger
2016-11-21 11:16 ` andrew-ct chen [this message]

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=1479726989.25126.2.camel@mtksdaap41 \
    --to=andrew-ct.chen@mediatek.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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