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

slimbus: qcom-ngd: Add error handling in of_qcom_slim_ngd_register

No error handling is performed when platform_device_add()
return fails. Refer to the error handling of driver_set_override(),
add error handling for platform_device_add().

Fixes: 917809e2280b ("slimbus: ngd: Add qcom SLIMBus NGD driver")
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Signed-off-by: Lin Yujun <linyujun809@huawei.com>
Link: https://lore.kernel.org/r/20220914031953.94061-1-linyujun809@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Lin Yujun and committed by
Greg Kroah-Hartman
42992cf1 bd124456

+7 -1
+7 -1
drivers/slimbus/qcom-ngd-ctrl.c
··· 1470 1470 ngd->pdev->dev.of_node = node; 1471 1471 ctrl->ngd = ngd; 1472 1472 1473 - platform_device_add(ngd->pdev); 1473 + ret = platform_device_add(ngd->pdev); 1474 + if (ret) { 1475 + platform_device_put(ngd->pdev); 1476 + kfree(ngd); 1477 + of_node_put(node); 1478 + return ret; 1479 + } 1474 1480 ngd->base = ctrl->base + ngd->id * data->offset + 1475 1481 (ngd->id - 1) * data->size; 1476 1482