Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mtd: physmap-core: Fix NULL pointer dereferencing in of_select_probe_type()

Coverity complains of a possible NULL dereference:

in of_select_probe_type():
1. returned_null: of_match_device() returns NULL.
2. var_assigned: match = NULL return value from of_match_device()
309 match = of_match_device(of_flash_match, &dev->dev);

3.dereference: Dereferencing the NULL pointer match.
310 probe_type = match->data;

Signed-off-by: Zeng Jingxiang <linuszeng@tencent.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20220727060302.1560325-1-zengjx95@gmail.com

authored by

Zeng Jingxiang and committed by
Miquel Raynal
8b740c08 26e78443

+3
+3
drivers/mtd/maps/physmap-core.c
··· 300 300 const char *probe_type; 301 301 302 302 match = of_match_device(of_flash_match, &dev->dev); 303 + if (!match) 304 + return NULL; 305 + 303 306 probe_type = match->data; 304 307 if (probe_type) 305 308 return probe_type;