tpmdd-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
To: "Gustavo A. R. Silva" <garsilva-L1vi/lXTdts+Va1GwOuvDg@public.gmane.org>
Cc: tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH] char: tmp: fix potential null pointer dereference
Date: Wed, 31 May 2017 15:11:29 +0300	[thread overview]
Message-ID: <20170531121129.f3576lq7peott6gd@intel.com> (raw)
In-Reply-To: <20170530215123.GA7484@embeddedgus>

On Tue, May 30, 2017 at 04:51:23PM -0500, Gustavo A. R. Silva wrote:
> NULL check at line 147: if (chip) {, implies chip might be NULL.
> Function dev_get_drvdata() dereference pointer chip.
> Move pointer priv assignment inside the IF block that checks
> pointer chip.
> 
> Addresses-Coverity-ID: 1397646
> Signed-off-by: Gustavo A. R. Silva <garsilva-L1vi/lXTdts+Va1GwOuvDg@public.gmane.org>

It cannot be.

/Jarkko

> ---
>  drivers/char/tpm/tpm_atmel.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/char/tpm/tpm_atmel.c b/drivers/char/tpm/tpm_atmel.c
> index 0d322ab..0826efd 100644
> --- a/drivers/char/tpm/tpm_atmel.c
> +++ b/drivers/char/tpm/tpm_atmel.c
> @@ -142,9 +142,10 @@ static struct platform_device *pdev;
>  static void atml_plat_remove(void)
>  {
>  	struct tpm_chip *chip = dev_get_drvdata(&pdev->dev);
> -	struct tpm_atmel_priv *priv = dev_get_drvdata(&chip->dev);
> +	struct tpm_atmel_priv *priv;
>  
>  	if (chip) {
> +		priv = dev_get_drvdata(&chip->dev);
>  		tpm_chip_unregister(chip);
>  		if (priv->have_region)
>  			atmel_release_region(priv->base, priv->region_size);
> -- 
> 2.5.0
> 

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

  reply	other threads:[~2017-05-31 12:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-30 21:51 [PATCH] char: tmp: fix potential null pointer dereference Gustavo A. R. Silva
2017-05-31 12:11 ` Jarkko Sakkinen [this message]
     [not found]   ` <20170531121129.f3576lq7peott6gd-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-06-12 22:25     ` Gustavo A. R. Silva
2017-06-13 18:03       ` Jarkko Sakkinen
2017-06-13 19:55         ` [PATCH] char: tpm: remove unnecessary NULL check Gustavo A. R. Silva
2017-06-14  9:46           ` Jarkko Sakkinen
2017-06-19  0:35           ` Jarkko Sakkinen

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=20170531121129.f3576lq7peott6gd@intel.com \
    --to=jarkko.sakkinen-vuqaysv1563yd54fqh9/ca@public.gmane.org \
    --cc=garsilva-L1vi/lXTdts+Va1GwOuvDg@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.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;
as well as URLs for NNTP newsgroup(s).