summaryrefslogtreecommitdiff
path: root/drivers/base/soc.c
diff options
context:
space:
mode:
authorGeert Uytterhoeven <geert+renesas@glider.be>2016-10-03 17:43:41 +0200
committerGeert Uytterhoeven <geert+renesas@glider.be>2016-11-10 10:10:33 +0100
commitab6a713e7dc2f92ad3bc3387122524655431501e (patch)
tree2c77f6c81d3665f4e1af5c75d1a989fa55dfd17b /drivers/base/soc.c
parentc97db7cc7778e34a53b42d58c766f0ec0e30d580 (diff)
base: soc: Check for NULL SoC device attributes
If soc_device_match() is used to check the value of a specific attribute that is not present for the current SoC, the kernel crashes with a NULL pointer dereference. Fix this by explicitly checking for the absence of a needed property, and considering this a non-match. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Acked-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/base/soc.c')
-rw-r--r--drivers/base/soc.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/base/soc.c b/drivers/base/soc.c
index 04ee597fc3a3..dc26e5949a32 100644
--- a/drivers/base/soc.c
+++ b/drivers/base/soc.c
@@ -176,19 +176,23 @@ static int soc_device_match_one(struct device *dev, void *arg)
const struct soc_device_attribute *match = arg;
if (match->machine &&
- !glob_match(match->machine, soc_dev->attr->machine))
+ (!soc_dev->attr->machine ||
+ !glob_match(match->machine, soc_dev->attr->machine)))
return 0;
if (match->family &&
- !glob_match(match->family, soc_dev->attr->family))
+ (!soc_dev->attr->family ||
+ !glob_match(match->family, soc_dev->attr->family)))
return 0;
if (match->revision &&
- !glob_match(match->revision, soc_dev->attr->revision))
+ (!soc_dev->attr->revision ||
+ !glob_match(match->revision, soc_dev->attr->revision)))
return 0;
if (match->soc_id &&
- !glob_match(match->soc_id, soc_dev->attr->soc_id))
+ (!soc_dev->attr->soc_id ||
+ !glob_match(match->soc_id, soc_dev->attr->soc_id)))
return 0;
return 1;