提交 3e99fae2 编写于 作者: K Kangjie Lu 提交者: Xie XiuQi

slimbus: fix a potential NULL pointer dereference in of_qcom_slim_ngd_register

[ Upstream commit 06d5d6b7f9948a89543e1160ef852d57892c750d ]

In case platform_device_alloc fails, the fix returns an error
code to avoid the NULL pointer dereference.
Signed-off-by: NKangjie Lu <kjlu@umn.edu>
Signed-off-by: NSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 8a254f79
...@@ -1331,6 +1331,10 @@ static int of_qcom_slim_ngd_register(struct device *parent, ...@@ -1331,6 +1331,10 @@ static int of_qcom_slim_ngd_register(struct device *parent,
return -ENOMEM; return -ENOMEM;
ngd->pdev = platform_device_alloc(QCOM_SLIM_NGD_DRV_NAME, id); ngd->pdev = platform_device_alloc(QCOM_SLIM_NGD_DRV_NAME, id);
if (!ngd->pdev) {
kfree(ngd);
return -ENOMEM;
}
ngd->id = id; ngd->id = id;
ngd->pdev->dev.parent = parent; ngd->pdev->dev.parent = parent;
ngd->pdev->driver_override = QCOM_SLIM_NGD_DRV_NAME; ngd->pdev->driver_override = QCOM_SLIM_NGD_DRV_NAME;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册