Skip to contentSkip to conversation

drivers/ata/libata-zpodd.c:83 zpodd_wake_dev() warn: variable dereferenced before check 'ata_dev' (see line 80)

PATCH In review Dan Carpenter 3 participants 5 messages Jan 22, 2013 – Jan 25, 2013 libata

lore
Share & tools
lore
#0 lore raw

PATCH 7/11 drivers/ata/libata-zpodd.c:83 zpodd_wake_dev() warn: variable dereferenced before check 'ata_dev' (see line 80)

Hi Aaron,

FYI, there are new smatch warnings show up in

tree:   git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev.git upstream
head:   7e15e9be37eb834aaaca69030064ac97eaf5df2f
commit: f064a20dded807448669426c9bfb7d03aba5659c [7/11] libata: move acpi notification code to zpodd

New smatch warnings:
drivers/ata/libata-zpodd.c:83 zpodd_wake_dev() warn: variable dereferenced before check 'ata_dev' (see line 80)

git remote add libata git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev.git
git remote update libata
git checkout f064a20dded807448669426c9bfb7d03aba5659c
vim +/ata_dev +83 drivers/ata/libata-zpodd.c

afe75951 Aaron Lu 2013-01-15  74  	return acpi_device_can_poweroff(acpi_dev);
afe75951 Aaron Lu 2013-01-15  75  }
afe75951 Aaron Lu 2013-01-15  76  
f064a20d Aaron Lu 2013-01-15  77  static void zpodd_wake_dev(acpi_handle handle, u32 event, void *context)
f064a20d Aaron Lu 2013-01-15  78  {
f064a20d Aaron Lu 2013-01-15  79  	struct ata_device *ata_dev = context;
f064a20d Aaron Lu 2013-01-15 @80  	struct zpodd *zpodd = ata_dev->zpodd;
f064a20d Aaron Lu 2013-01-15  81  	struct device *dev = &ata_dev->sdev->sdev_gendev;
f064a20d Aaron Lu 2013-01-15  82  
f064a20d Aaron Lu 2013-01-15 @83  	if (event == ACPI_NOTIFY_DEVICE_WAKE && ata_dev &&
f064a20d Aaron Lu 2013-01-15  84  			pm_runtime_suspended(dev)) {
f064a20d Aaron Lu 2013-01-15  85  		zpodd->from_notify = true;
f064a20d Aaron Lu 2013-01-15  86  		pm_runtime_resume(dev);

---
0-DAY kernel build testing backend Open Source Technology Center
http://lists.01.org/mailman/listinfo/kbuild Intel Corporation

#1 lore raw

Hi Dan,

Thanks for the remind.

Quoted 10 lines · Dan Carpenter

Hi Aaron,

FYI, there are new smatch warnings show up in

tree:   git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev.git upstream
head:   7e15e9be37eb834aaaca69030064ac97eaf5df2f
commit: f064a20dded807448669426c9bfb7d03aba5659c [7/11] libata: move acpi notification code to zpodd

New smatch warnings:
drivers/ata/libata-zpodd.c:83 zpodd_wake_dev() warn: variable dereferenced before check 'ata_dev' (see line 80)

The ata_dev variable shouldn't ever be NULL here.

Quoted 12 lines

git remote add libata git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev.git
git remote update libata
git checkout f064a20dded807448669426c9bfb7d03aba5659c
vim +/ata_dev +83 drivers/ata/libata-zpodd.c

afe75951 Aaron Lu 2013-01-15  74  	return acpi_device_can_poweroff(acpi_dev);
afe75951 Aaron Lu 2013-01-15  75  }
afe75951 Aaron Lu 2013-01-15  76  
f064a20d Aaron Lu 2013-01-15  77  static void zpodd_wake_dev(acpi_handle handle, u32 event, void *context)
f064a20d Aaron Lu 2013-01-15  78  {
f064a20d Aaron Lu 2013-01-15  79  	struct ata_device *ata_dev = context;
Quoted 4 lines

f064a20d Aaron Lu 2013-01-15 @80 struct zpodd *zpodd = ata_dev->zpodd;
f064a20d Aaron Lu 2013-01-15 81 struct device *dev = &ata_dev->sdev->sdev_gendev;
f064a20d Aaron Lu 2013-01-15 82
f064a20d Aaron Lu 2013-01-15 @83 if (event == ACPI_NOTIFY_DEVICE_WAKE && ata_dev &&

If I remove the check for ata_dev here, will the smatch warning go away? Or should I add a check above? I suppose we need to do something to the warning, so that it won't pop up in the future, so please feel free to suggest, thanks!

-Aaron

Quoted 8 lines
f064a20d Aaron Lu 2013-01-15  84  			pm_runtime_suspended(dev)) {
f064a20d Aaron Lu 2013-01-15  85  		zpodd->from_notify = true;
f064a20d Aaron Lu 2013-01-15  86  		pm_runtime_resume(dev);

---
0-DAY kernel build testing backend Open Source Technology Center
http://lists.01.org/mailman/listinfo/kbuild Intel Corporation

#2 lore raw
Quoted 35 lines · Aaron Lu

Hi Dan,

Thanks for the remind.

Quoted 10 lines · Dan Carpenter

Hi Aaron,

FYI, there are new smatch warnings show up in

tree:   git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev.git upstream
head:   7e15e9be37eb834aaaca69030064ac97eaf5df2f
commit: f064a20dded807448669426c9bfb7d03aba5659c [7/11] libata: move acpi notification code to zpodd

New smatch warnings:
drivers/ata/libata-zpodd.c:83 zpodd_wake_dev() warn: variable dereferenced before check 'ata_dev' (see line 80)

The ata_dev variable shouldn't ever be NULL here.

Quoted 12 lines

git remote add libata git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev.git
git remote update libata
git checkout f064a20dded807448669426c9bfb7d03aba5659c
vim +/ata_dev +83 drivers/ata/libata-zpodd.c

afe75951 Aaron Lu 2013-01-15  74  	return acpi_device_can_poweroff(acpi_dev);
afe75951 Aaron Lu 2013-01-15  75  }
afe75951 Aaron Lu 2013-01-15  76  
f064a20d Aaron Lu 2013-01-15  77  static void zpodd_wake_dev(acpi_handle handle, u32 event, void *context)
f064a20d Aaron Lu 2013-01-15  78  {
f064a20d Aaron Lu 2013-01-15  79  	struct ata_device *ata_dev = context;
Quoted 4 lines

f064a20d Aaron Lu 2013-01-15 @80 struct zpodd *zpodd = ata_dev->zpodd;
f064a20d Aaron Lu 2013-01-15 81 struct device *dev = &ata_dev->sdev->sdev_gendev;
f064a20d Aaron Lu 2013-01-15 82
f064a20d Aaron Lu 2013-01-15 @83 if (event == ACPI_NOTIFY_DEVICE_WAKE && ata_dev &&

Quoted 4 lines

If I remove the check for ata_dev here, will the smatch warning go away? Or should I add a check above? I suppose we need to do something to the warning, so that it won't pop up in the future, so please feel free to suggest, thanks!

Removing the check would silence the warning.

regards,
dan carpenter

#3 lore raw
Quoted 36 lines · Dan Carpenter
Quoted 35 lines · Aaron Lu

Hi Dan,

Thanks for the remind.

Quoted 10 lines · Dan Carpenter

Hi Aaron,

FYI, there are new smatch warnings show up in

tree:   git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev.git upstream
head:   7e15e9be37eb834aaaca69030064ac97eaf5df2f
commit: f064a20dded807448669426c9bfb7d03aba5659c [7/11] libata: move acpi notification code to zpodd

New smatch warnings:
drivers/ata/libata-zpodd.c:83 zpodd_wake_dev() warn: variable dereferenced before check 'ata_dev' (see line 80)

The ata_dev variable shouldn't ever be NULL here.

Quoted 16 lines

git remote add libata git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev.git
git remote update libata
git checkout f064a20dded807448669426c9bfb7d03aba5659c
vim +/ata_dev +83 drivers/ata/libata-zpodd.c

afe75951 Aaron Lu 2013-01-15  74  	return acpi_device_can_poweroff(acpi_dev);
afe75951 Aaron Lu 2013-01-15  75  }
afe75951 Aaron Lu 2013-01-15  76  
f064a20d Aaron Lu 2013-01-15  77  static void zpodd_wake_dev(acpi_handle handle, u32 event, void *context)
f064a20d Aaron Lu 2013-01-15  78  {
f064a20d Aaron Lu 2013-01-15  79  	struct ata_device *ata_dev = context;

f064a20d Aaron Lu 2013-01-15 @80 struct zpodd *zpodd = ata_dev->zpodd;
f064a20d Aaron Lu 2013-01-15 81 struct device *dev = &ata_dev->sdev->sdev_gendev;
f064a20d Aaron Lu 2013-01-15 82
f064a20d Aaron Lu 2013-01-15 @83 if (event == ACPI_NOTIFY_DEVICE_WAKE && ata_dev &&

Quoted 6 lines
Quoted 4 lines

If I remove the check for ata_dev here, will the smatch warning go away? Or should I add a check above? I suppose we need to do something to the warning, so that it won't pop up in the future, so please feel free to suggest, thanks!

Removing the check would silence the warning.

OK, thanks.

Hi Jeff,
Should I prepare a new patch to fix this or update the original patch?

Thanks,
Aaron

#4 lore raw
Quoted 42 lines · Aaron Lu
Quoted 41 lines · Dan Carpenter
Quoted 39 lines · Aaron Lu

Hi Dan,

Thanks for the remind.

Quoted 10 lines · Dan Carpenter

Hi Aaron,

FYI, there are new smatch warnings show up in

tree:   git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev.git upstream
head:   7e15e9be37eb834aaaca69030064ac97eaf5df2f
commit: f064a20dded807448669426c9bfb7d03aba5659c [7/11] libata: move acpi notification code to zpodd

New smatch warnings:
drivers/ata/libata-zpodd.c:83 zpodd_wake_dev() warn: variable dereferenced before check 'ata_dev' (see line 80)

The ata_dev variable shouldn't ever be NULL here.

Quoted 12 lines

git remote add libata git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev.git
git remote update libata
git checkout f064a20dded807448669426c9bfb7d03aba5659c
vim +/ata_dev +83 drivers/ata/libata-zpodd.c

afe75951 Aaron Lu 2013-01-15  74  	return acpi_device_can_poweroff(acpi_dev);
afe75951 Aaron Lu 2013-01-15  75  }
afe75951 Aaron Lu 2013-01-15  76
f064a20d Aaron Lu 2013-01-15  77  static void zpodd_wake_dev(acpi_handle handle, u32 event, void *context)
f064a20d Aaron Lu 2013-01-15  78  {
f064a20d Aaron Lu 2013-01-15  79  	struct ata_device *ata_dev = context;
Quoted 4 lines

f064a20d Aaron Lu 2013-01-15 @80 struct zpodd *zpodd = ata_dev->zpodd;
f064a20d Aaron Lu 2013-01-15 81 struct device *dev = &ata_dev->sdev->sdev_gendev;
f064a20d Aaron Lu 2013-01-15 82
f064a20d Aaron Lu 2013-01-15 @83 if (event == ACPI_NOTIFY_DEVICE_WAKE && ata_dev &&

If I remove the check for ata_dev here, will the smatch warning go away? Or should I add a check above? I suppose we need to do something to the warning, so that it won't pop up in the future, so please feel free to suggest, thanks!

Quoted 6 lines
Quoted 1 line

Removing the check would silence the warning.

OK, thanks.

Hi Jeff,
Should I prepare a new patch to fix this or update the original patch?

If it's in libata-dev.git#upstream, then a patch on top of all the others, which addresses the issue.

Jeff