[PATCH 1/2] peci: fix error-handling in peci_dev_ioctl()

Joel Stanley joel at jms.id.au
Tue Sep 29 15:55:39 AEST 2020


On Sat, 26 Sep 2020 at 21:27, Zev Weiss <zev at bewilderbeest.net> wrote:
>
> peci_get_xfer_msg() returns NULL on failure, not an ERR_PTR.  Also
> avoid calling kfree() on an ERR_PTR.
>
> Signed-off-by: Zev Weiss <zev at bewilderbeest.net>

Fixes: 90ddc4e972b5 ("peci: Add support for PECI bus driver core")
Reviewed-by: Joel Stanley <joel at jms.id.au>

Applied to dev-5.8.

Cheers,

Joel

> ---
>  drivers/peci/peci-dev.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/peci/peci-dev.c b/drivers/peci/peci-dev.c
> index e0fe09467a80..84e90af81ccc 100644
> --- a/drivers/peci/peci-dev.c
> +++ b/drivers/peci/peci-dev.c
> @@ -122,8 +122,8 @@ static long peci_dev_ioctl(struct file *file, uint iocmd, ulong arg)
>                 }
>
>                 xmsg = peci_get_xfer_msg(uxmsg.tx_len, uxmsg.rx_len);
> -               if (IS_ERR(xmsg)) {
> -                       ret = PTR_ERR(xmsg);
> +               if (!xmsg) {
> +                       ret = -ENOMEM;
>                         break;
>                 }
>
> @@ -162,7 +162,8 @@ static long peci_dev_ioctl(struct file *file, uint iocmd, ulong arg)
>         }
>
>         peci_put_xfer_msg(xmsg);
> -       kfree(msg);
> +       if (!IS_ERR(msg))
> +               kfree(msg);
>
>         return (long)ret;
>  }
> --
> 2.28.0
>


More information about the openbmc mailing list