From: Aditya Pakki Date: Fri, 22 Mar 2019 21:55:03 +0000 (-0500) Subject: firmware: arm_scmi: replace of_match_device->data with of_device_get_match_data() X-Git-Tag: v5.2-rc1~44^2~15^2 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=d9350f21e5fe2614e1f78ef20c3a3e83c4a36391;p=linux-block.git firmware: arm_scmi: replace of_match_device->data with of_device_get_match_data() of_match_device can return NULL if no matching device is found though it's highly unlikely to happen in scmi_probe as it's called only if a valid match is found. However we can use of_device_get_match_data() instead of of_match_device()->data to handle NULL pointer checks and return -EINVAL in such a scenario. Reviewed-by: Steven Price Signed-off-by: Aditya Pakki Signed-off-by: Sudeep Holla --- diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index dd967d675c08..b5bc4c7a8fab 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -796,7 +796,9 @@ static int scmi_probe(struct platform_device *pdev) return -EINVAL; } - desc = of_match_device(scmi_of_match, dev)->data; + desc = of_device_get_match_data(dev); + if (!desc) + return -EINVAL; info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL); if (!info)