* [PATCH] char: tmp: fix potential null pointer dereference
@ 2017-05-30 21:51 Gustavo A. R. Silva
2017-05-31 12:11 ` Jarkko Sakkinen
0 siblings, 1 reply; 7+ messages in thread
From: Gustavo A. R. Silva @ 2017-05-30 21:51 UTC (permalink / raw)
To: Peter Huewe, Marcel Selhorst, Jarkko Sakkinen, Jason Gunthorpe
Cc: tpmdd-devel, linux-kernel, Gustavo A. R. Silva
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>
---
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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] char: tmp: fix potential null pointer dereference
2017-05-30 21:51 [PATCH] char: tmp: fix potential null pointer dereference Gustavo A. R. Silva
@ 2017-05-31 12:11 ` Jarkko Sakkinen
[not found] ` <20170531121129.f3576lq7peott6gd-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
0 siblings, 1 reply; 7+ messages in thread
From: Jarkko Sakkinen @ 2017-05-31 12:11 UTC (permalink / raw)
To: Gustavo A. R. Silva
Cc: tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] char: tmp: fix potential null pointer dereference
[not found] ` <20170531121129.f3576lq7peott6gd-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
@ 2017-06-12 22:25 ` Gustavo A. R. Silva
2017-06-13 18:03 ` Jarkko Sakkinen
0 siblings, 1 reply; 7+ messages in thread
From: Gustavo A. R. Silva @ 2017-06-12 22:25 UTC (permalink / raw)
To: Jarkko Sakkinen
Cc: tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
Hi Jarkko,
Please, see my comments below
Quoting Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>:
> 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.
>
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?
>> + 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
>>
Thank you
--
Gustavo A. R. Silva
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] char: tmp: fix potential null pointer dereference
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
0 siblings, 1 reply; 7+ messages in thread
From: Jarkko Sakkinen @ 2017-06-13 18:03 UTC (permalink / raw)
To: Gustavo A. R. Silva
Cc: Peter Huewe, Marcel Selhorst, Jason Gunthorpe, tpmdd-devel, linux-kernel
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] char: tpm: remove unnecessary NULL check
2017-06-13 18:03 ` Jarkko Sakkinen
@ 2017-06-13 19:55 ` Gustavo A. R. Silva
2017-06-14 9:46 ` Jarkko Sakkinen
2017-06-19 0:35 ` Jarkko Sakkinen
0 siblings, 2 replies; 7+ messages in thread
From: Gustavo A. R. Silva @ 2017-06-13 19:55 UTC (permalink / raw)
To: Jarkko Sakkinen, Peter Huewe, Marcel Selhorst, Jason Gunthorpe
Cc: tpmdd-devel, linux-kernel, Gustavo A. R. Silva
Remove unnecessary NULL check.
Pointer _chip_ cannot be NULL in this instance.
Addresses-Coverity-ID: 1397646
Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
---
drivers/char/tpm/tpm_atmel.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/drivers/char/tpm/tpm_atmel.c b/drivers/char/tpm/tpm_atmel.c
index 0d322ab..66a1452 100644
--- a/drivers/char/tpm/tpm_atmel.c
+++ b/drivers/char/tpm/tpm_atmel.c
@@ -144,13 +144,11 @@ 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);
- if (chip) {
- tpm_chip_unregister(chip);
- if (priv->have_region)
- atmel_release_region(priv->base, priv->region_size);
- atmel_put_base_addr(priv->iobase);
- platform_device_unregister(pdev);
- }
+ tpm_chip_unregister(chip);
+ if (priv->have_region)
+ atmel_release_region(priv->base, priv->region_size);
+ atmel_put_base_addr(priv->iobase);
+ platform_device_unregister(pdev);
}
static SIMPLE_DEV_PM_OPS(tpm_atml_pm, tpm_pm_suspend, tpm_pm_resume);
--
2.5.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] char: tpm: remove unnecessary NULL check
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
1 sibling, 0 replies; 7+ messages in thread
From: Jarkko Sakkinen @ 2017-06-14 9:46 UTC (permalink / raw)
To: Gustavo A. R. Silva
Cc: tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
On Tue, Jun 13, 2017 at 02:55:42PM -0500, Gustavo A. R. Silva wrote:
> Remove unnecessary NULL check.
> Pointer _chip_ cannot be NULL in this instance.
>
> Addresses-Coverity-ID: 1397646
> Cc: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
> Signed-off-by: Gustavo A. R. Silva <garsilva-L1vi/lXTdts+Va1GwOuvDg@public.gmane.org>
> ---
> drivers/char/tpm/tpm_atmel.c | 12 +++++-------
> 1 file changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/char/tpm/tpm_atmel.c b/drivers/char/tpm/tpm_atmel.c
> index 0d322ab..66a1452 100644
> --- a/drivers/char/tpm/tpm_atmel.c
> +++ b/drivers/char/tpm/tpm_atmel.c
> @@ -144,13 +144,11 @@ 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);
>
> - if (chip) {
> - tpm_chip_unregister(chip);
> - if (priv->have_region)
> - atmel_release_region(priv->base, priv->region_size);
> - atmel_put_base_addr(priv->iobase);
> - platform_device_unregister(pdev);
> - }
> + tpm_chip_unregister(chip);
> + if (priv->have_region)
> + atmel_release_region(priv->base, priv->region_size);
> + atmel_put_base_addr(priv->iobase);
> + platform_device_unregister(pdev);
> }
>
> static SIMPLE_DEV_PM_OPS(tpm_atml_pm, tpm_pm_suspend, tpm_pm_resume);
> --
> 2.5.0
>
Thank you.
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
/Jarkko
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] char: tpm: remove unnecessary NULL check
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
1 sibling, 0 replies; 7+ messages in thread
From: Jarkko Sakkinen @ 2017-06-19 0:35 UTC (permalink / raw)
To: Gustavo A. R. Silva, Peter Huewe, Marcel Selhorst, Jason Gunthorpe
Cc: tpmdd-devel, linux-kernel
On Tue, 2017-06-13 at 14:55 -0500, Gustavo A. R. Silva wrote:
> Remove unnecessary NULL check.
> Pointer _chip_ cannot be NULL in this instance.
>
> Addresses-Coverity-ID: 1397646
> Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkine@linux.intel.com>
Tested-by: Jarkko Sakkinen <jarkko.sakkine@linux.intel.com>
(compilation)
/Jarkko
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-06-19 0:35 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-30 21:51 [PATCH] char: tmp: fix potential null pointer dereference Gustavo A. R. Silva
2017-05-31 12:11 ` Jarkko Sakkinen
[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
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).