diff options
author | Geert Uytterhoeven <geert+renesas@glider.be> | 2016-10-03 15:43:41 (GMT) |
---|---|---|
committer | Xie Xiaobo <xiaobo.xie@nxp.com> | 2017-07-14 10:28:15 (GMT) |
commit | 5e985fc7dffd7340168815768d5b85836be0384f (patch) | |
tree | ae587e5a00f2be406ecb8ae10002abca329422f2 | |
parent | 546ef30819e36bc25b49331c2898c8819bf6b642 (diff) | |
download | linux-5e985fc7dffd7340168815768d5b85836be0384f.tar.xz |
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>
-rw-r--r-- | drivers/base/soc.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/base/soc.c b/drivers/base/soc.c index 0c5cf87..0e701e2 100644 --- a/drivers/base/soc.c +++ b/drivers/base/soc.c @@ -167,19 +167,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; |