linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tiffany Lin <tiffany.lin@mediatek.com>
To: Colin King <colin.king@canonical.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	Hans Verkuil <hans.verkuil@cisco.com>,
	"Wei Yongjun" <yongjun_wei@trendmicro.com.cn>,
	Andrew-CT Chen <andrew-ct.chen@mediatek.com>,
	<linux-media@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-mediatek@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] [media] VPU: mediatek: fix null pointer dereference on pdev
Date: Thu, 8 Sep 2016 13:21:46 +0800	[thread overview]
Message-ID: <1473312106.22713.1.camel@mtksdaap41> (raw)
In-Reply-To: <20160907171027.16424-1-colin.king@canonical.com>

On Wed, 2016-09-07 at 18:10 +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> pdev is being null checked, however, prior to that it is being
> dereferenced by platform_get_drvdata.  Move the assignments of
> vpu and run to after the pdev null check to avoid a potential
> null pointer dereference.
> 

Reviewed-by:Tiffany Lin <tiffany.lin@mediatek.com>

> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/media/platform/mtk-vpu/mtk_vpu.c | 7 +++++--
>  1 file changed, 5 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..43907a3 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;
>  
> @@ -534,6 +534,9 @@ int vpu_load_firmware(struct platform_device *pdev)
>  		return -EINVAL;
>  	}
>  
> +	vpu = platform_get_drvdata(pdev);
> +	run = &vpu->run;
> +
>  	mutex_lock(&vpu->vpu_mutex);
>  	if (vpu->fw_loaded) {
>  		mutex_unlock(&vpu->vpu_mutex);

  reply	other threads:[~2016-09-08  6:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-07 17:10 [PATCH] [media] VPU: mediatek: fix null pointer dereference on pdev Colin King
2016-09-08  5:21 ` Tiffany Lin [this message]
2016-09-09  1:25 ` andrew-ct chen

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=1473312106.22713.1.camel@mtksdaap41 \
    --to=tiffany.lin@mediatek.com \
    --cc=andrew-ct.chen@mediatek.com \
    --cc=colin.king@canonical.com \
    --cc=hans.verkuil@cisco.com \
    --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=yongjun_wei@trendmicro.com.cn \
    /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).