Re: [PATCH] Arch: arm: plat-pxa - Fix possible NULL derefrence.
From: Russell King - ARM Linux
Date: Mon Jan 30 2017 - 14:08:29 EST
On Mon, Jan 30, 2017 at 10:28:31AM +0530, Shailendra Verma wrote:
> of_match_device could return NULL, and so can cause a NULL
> pointer dereference later.
Please explain how this can happen.
The driver is matched to the device via the driver model looking up
the compatible string in the match table:
.of_match_table = of_match_ptr(pxa_ssp_of_ids),
It then calls the probe function, which notices that there's a DT
node pointer, and the driver looks the device up in the very same
table.
If the driver model found a match and then the device driver didn't
for the very same device, something really bad went wrong.
So, if you want to add something:
if (WARN_ON(!id))
return -ENODEV;
should be about it, since it's something we expect to never encounter.
--
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.