Blob Blame History Raw
From c545f637f81ebab88c257a243083a879af0b85b7 Mon Sep 17 00:00:00 2001
From: Robin Murphy <robin.murphy@arm.com>
Date: Wed, 15 Nov 2017 12:50:06 +0000
Subject: [PATCH] of/pci: Fix theoretical NULL dereference
Git-commit: c545f637f81ebab88c257a243083a879af0b85b7
Patch-mainline: v4.15-rc1
References: bsc#1051510

In the (relatively mechanical) process of adapting the RID-mapping code
to put the resulting ID in an output argument rather than the funtion
return value, we ended up with the debug print using the argument
pointer rather than the local value, which potentially defeats the
earlier NULL check.

Fixes: 987068fcbdb7: "of/irq: Break out msi-map lookup (again)"
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Rob Herring <robh@kernel.org>
Acked-by: Takashi Iwai <tiwai@suse.de>

---
 drivers/of/of_pci.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/of/of_pci.c
+++ b/drivers/of/of_pci.c
@@ -374,7 +374,7 @@ int of_pci_map_rid(struct device_node *n
 
 		pr_debug("%pOF: %s, using mask %08x, rid-base: %08x, out-base: %08x, length: %08x, rid: %08x -> %08x\n",
 			np, map_name, map_mask, rid_base, out_base,
-			rid_len, rid, *id_out);
+			rid_len, rid, masked_rid - rid_base + out_base);
 		return 0;
 	}