Re: [PATCH] Sony-laptop: Use common error handling code in sony_nc_setup_rfkill()

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

 



On Mon, Oct 30, 2017 at 10:15 PM, SF Markus Elfring
<elfring@xxxxxxxxxxxxxxxxxxxxx> wrote:
> From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
> Date: Mon, 30 Oct 2017 21:10:49 +0100
>
> Add a jump target so that a bit of exception handling can be better reused
> at the end of this function.
>
> This issue was detected by using the Coccinelle software.

Apparently this patch done without reading the actual code.

NAK.

-1 is EPERM which sounds wrong here. If you would like to fix it,
propagate a real error codes from sony_call_snc_handle().

>         if (!rfk)
>                 return -ENOMEM;

Okay error code.

>
> -       if (sony_call_snc_handle(sony_rfkill_handle, 0x200, &result) < 0) {
> -               rfkill_destroy(rfk);
> -               return -1;

Not okay.

> -       }
> +       if (sony_call_snc_handle(sony_rfkill_handle, 0x200, &result) < 0)
> +               goto destroy_rfk;
> +
>         hwblock = !(result & 0x1);
>
>         if (sony_call_snc_handle(sony_rfkill_handle,
> -                               sony_rfkill_address[nc_type],
> -                               &result) < 0) {
> -               rfkill_destroy(rfk);
> -               return -1;

Not okay and it might be different from previous case.

> -       }
> +                                sony_rfkill_address[nc_type],
> +                                &result) < 0)
> +               goto destroy_rfk;
> +
>         swblock = !(result & 0x2);
>
>         rfkill_init_sw_state(rfk, swblock);
> @@ -1684,6 +1682,10 @@ static int sony_nc_setup_rfkill(struct acpi_device *device,
>         }
>         sony_rfkill_devices[nc_type] = rfk;
>         return err;
> +
> +destroy_rfk:
> +       rfkill_destroy(rfk);
> +       return -1;

P.S. Don't bother us with patches on which you didn't do your home work.
Thanks for understanding.

-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux