* [PATCH 5/10] drivers/pci: Move a dereference below a NULL test
@ 2009-07-19 15:26 Julia Lawall
2009-09-17 17:12 ` Jesse Barnes
0 siblings, 1 reply; 2+ messages in thread
From: Julia Lawall @ 2009-07-19 15:26 UTC (permalink / raw)
To: kristen.c.accardi, linux-pci, linux-kernel, kernel-janitors
From: Julia Lawall <julia@diku.dk>
If the NULL test is necessary, then the dereference should be moved below
the NULL test.
The semantic patch that finds this problem is as follows:
(http://www.emn.fr/x-info/coccinelle/)
// <smpl>
@@
type T;
expression E,E1;
identifier i,fld;
statement S;
@@
- T i = E->fld;
+ T i;
... when != E=E1
when != i
if (E == NULL||...) S
+ i = E->fld;
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
---
drivers/pci/pcie/aspm.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
index 3d27c97..fc8311b 100644
--- a/drivers/pci/pcie/aspm.c
+++ b/drivers/pci/pcie/aspm.c
@@ -668,10 +668,11 @@ out:
void pcie_aspm_exit_link_state(struct pci_dev *pdev)
{
struct pci_dev *parent = pdev->bus->self;
- struct pcie_link_state *link_state = parent->link_state;
+ struct pcie_link_state *link_state;
- if (aspm_disabled || !pdev->is_pcie || !parent || !link_state)
+ if (aspm_disabled || !pdev->is_pcie || !parent || !parent->link_state)
return;
+ link_state = parent->link_state;
if (parent->pcie_type != PCI_EXP_TYPE_ROOT_PORT &&
parent->pcie_type != PCI_EXP_TYPE_DOWNSTREAM)
return;
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH 5/10] drivers/pci: Move a dereference below a NULL test
2009-07-19 15:26 [PATCH 5/10] drivers/pci: Move a dereference below a NULL test Julia Lawall
@ 2009-09-17 17:12 ` Jesse Barnes
0 siblings, 0 replies; 2+ messages in thread
From: Jesse Barnes @ 2009-09-17 17:12 UTC (permalink / raw)
To: Julia Lawall; +Cc: kristen.c.accardi, linux-pci, linux-kernel, kernel-janitors
On Sun, 19 Jul 2009 17:26:58 +0200 (CEST)
Julia Lawall <julia@diku.dk> wrote:
> From: Julia Lawall <julia@diku.dk>
>
> If the NULL test is necessary, then the dereference should be moved
> below the NULL test.
>
> The semantic patch that finds this problem is as follows:
> (http://www.emn.fr/x-info/coccinelle/)
Sorry I missed this one. Looks like it's been fixed another way
though...
--
Jesse Barnes, Intel Open Source Technology Center
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-09-17 17:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-19 15:26 [PATCH 5/10] drivers/pci: Move a dereference below a NULL test Julia Lawall
2009-09-17 17:12 ` Jesse Barnes
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®