[PATCH] firmware: arm_scpi: Fix error handle when scpi probe failed

Sudeep Holla sudeep.holla at arm.com
Fri Jul 1 03:00:08 PDT 2022


On Fri, Jul 01, 2022 at 10:42:12AM +0100, Sudeep Holla wrote:
> diff --git i/drivers/firmware/arm_scpi.c w/drivers/firmware/arm_scpi.c
> index ddf0b9ff9e15..6fa1a5b193b8 100644
> --- i/drivers/firmware/arm_scpi.c
> +++ w/drivers/firmware/arm_scpi.c
> @@ -799,7 +799,7 @@ static struct scpi_ops scpi_ops = {
> 
>  struct scpi_ops *get_scpi_ops(void)
>  {
> -       return scpi_info ? scpi_info->scpi_ops : NULL;
> +       return scpi_info && scpi_info->scpi_ops ? scpi_info->scpi_ops : NULL;

Scratch that, scpi_info->scpi_ops will be NULL and it is fine to return NULL.

Only reason why something can go wrong is if devm_of_platform_populate()
fails and we return error after setting up scpi_info->scpi_ops.

Can you check if the below fixes the issue ? We can continue working as
a driver even if few of the devices were populated which could be the case
but I am still doubtful about that.

Regards,
Sudeep

-->8

diff --git i/drivers/firmware/arm_scpi.c w/drivers/firmware/arm_scpi.c
index ddf0b9ff9e15..bae2e18e24ee 100644
--- i/drivers/firmware/arm_scpi.c
+++ w/drivers/firmware/arm_scpi.c
@@ -1024,7 +1024,9 @@ static int scpi_probe(struct platform_device *pdev)
                                   scpi_info->firmware_version));
        scpi_info->scpi_ops = &scpi_ops;
 
-       return devm_of_platform_populate(dev);
+       devm_of_platform_populate(dev);
+
+       return ret;
 }




More information about the linux-arm-kernel mailing list