diff mbox

[1/1] cxl/vphb.c: Use phb pointer after NULL check

Message ID 1435574111-45617-1-git-send-email-maninder1.s@samsung.com (mailing list archive)
State Accepted
Delegated to: Michael Ellerman
Headers show

Commit Message

Maninder Singh June 29, 2015, 10:35 a.m. UTC
static Anlaysis detected below error:-
(error) Possible null pointer dereference: phb

So, Use phb after NULL check.

Signed-off-by: Maninder Singh <maninder1.s@samsung.com>
---
 drivers/misc/cxl/vphb.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Ian Munsie June 30, 2015, 3:27 a.m. UTC | #1
Acked-by: Ian Munsie <imunsie@au1.ibm.com>
Michael Ellerman July 7, 2015, 10:38 a.m. UTC | #2
On Mon, 2015-29-06 at 10:35:11 UTC, Maninder Singh wrote:
> static Anlaysis detected below error:-
> (error) Possible null pointer dereference: phb
> 
> So, Use phb after NULL check.
> 
> Signed-off-by: Maninder Singh <maninder1.s@samsung.com>
> Acked-by: Ian Munsie <imunsie@au1.ibm.com>

Applied to powerpc fixes, thanks.

https://git.kernel.org/cgit/linux/kernel/git/powerpc/linux.git/commit/?h=fixes&id=14f21189df33bc972455d6a0ed875aa68718d7fc

cheers
diff mbox

Patch

diff --git a/drivers/misc/cxl/vphb.c b/drivers/misc/cxl/vphb.c
index b1d1983a..2eba002 100644
--- a/drivers/misc/cxl/vphb.c
+++ b/drivers/misc/cxl/vphb.c
@@ -112,9 +112,10 @@  static int cxl_pcie_config_info(struct pci_bus *bus, unsigned int devfn,
 	unsigned long addr;
 
 	phb = pci_bus_to_host(bus);
-	afu = (struct cxl_afu *)phb->private_data;
 	if (phb == NULL)
 		return PCIBIOS_DEVICE_NOT_FOUND;
+	afu = (struct cxl_afu *)phb->private_data;
+
 	if (cxl_pcie_cfg_record(bus->number, devfn) > afu->crs_num)
 		return PCIBIOS_DEVICE_NOT_FOUND;
 	if (offset >= (unsigned long)phb->cfg_data)