Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1665090
| From | Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] char: tmp: fix potential null pointer dereference |
| Date | 2017-06-13 20:10 +0200 |
| Message-ID | <tRYqm-2Pr-19@gated-at.bofh.it> (permalink) |
| References | <tMXlh-4i6-51@gated-at.bofh.it> <tNaLv-4Cv-13@gated-at.bofh.it> <tRGtr-8hX-1@gated-at.bofh.it> |
| Organization | Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo |
On Mon, Jun 12, 2017 at 05:25:44PM -0500, Gustavo A. R. Silva wrote:
> Hi Jarkko,
>
> Please, see my comments below
>
> Quoting Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>:
>
> > 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@embeddedor.com>
> >
> > It cannot be.
> >
>
> I got it.
>
> > /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) {
>
> So, this NULL check could be removed?
Yes, this would be right way to fix it.
/Jarkko
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: [PATCH] char: tmp: fix potential null pointer dereference "Gustavo A. R. Silva" <garsilva@embeddedor.com> - 2017-06-13 01:00 +0200
Re: [PATCH] char: tmp: fix potential null pointer dereference Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2017-06-13 20:10 +0200
[PATCH] char: tpm: remove unnecessary NULL check "Gustavo A. R. Silva" <garsilva@embeddedor.com> - 2017-06-13 22:00 +0200
Re: [PATCH] char: tpm: remove unnecessary NULL check Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2017-06-14 11:50 +0200
Re: [PATCH] char: tpm: remove unnecessary NULL check Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2017-06-19 02:40 +0200
csiph-web