RE: [PATCH] misc: mchp_pci1xxxx: mchp_pci1xxxx_gp: add unwind goto

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> -----Original Message-----
> From: Xinyi Hou <Y_Ashley@xxxxxxx>
> Sent: Sunday, April 9, 2023 6:18 PM
> To: Kumaravel Thiagarajan - I21417
> <Kumaravel.Thiagarajan@xxxxxxxxxxxxx>; Arnd Bergmann
> <arnd@xxxxxxxx>; Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> 
> Smatch reported:
> 
> drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c:73 gp_aux_bus_probe()
> warn:
> missing unwind goto?
> 
> In gp_aux_bus_probe(), when the allocation of aux_bus-
> >aux_device_wrapper[1] fails, it needs to clean up the allocated resources.
> 
> Fix this by revising the return statement to a goto statement.
> 
> Fixes: 393fc2f5948f ("misc: microchip: pci1xxxx: load auxiliary bus driver for
> the PIO function in the multi-function endpoint of pci1xxxx device.")
> Signed-off-by: Xinyi Hou <Y_Ashley@xxxxxxx>
> Reviewed-by: Dongliang Mu <dzm91@xxxxxxxxxxx>
Reviewed-by: Kumaravel Thiagarajan <kumaravel.thiagarajan@xxxxxxxxxxxxx>
> ---
> The issue is found by static analysis, and the patch remains untest.
> ---
> 
>  drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c
> b/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c
> index 32af2b14ff34..2c64b6b3cd9c 100644
> --- a/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c
> +++ b/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c
> @@ -69,8 +69,10 @@ static int gp_aux_bus_probe(struct pci_dev *pdev,
> const struct pci_device_id *id
> 
>         aux_bus->aux_device_wrapper[1] = kzalloc(sizeof(*aux_bus-
> >aux_device_wrapper[1]),
>                                                  GFP_KERNEL);
> -       if (!aux_bus->aux_device_wrapper[1])
> -               return -ENOMEM;
> +       if (!aux_bus->aux_device_wrapper[1]) {
> +               retval = -ENOMEM;
> +               goto err_aux_dev_add_0;
> +       }
> 
>         retval = ida_alloc(&gp_client_ida, GFP_KERNEL);
>         if (retval < 0)
> --
> 2.25.1





[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux