Re: [PATCH] ppdev: check ida_simple_get() return value

From: Greg KH
Date: Fri Sep 09 2022 - 04:08:23 EST


On Tue, Sep 06, 2022 at 10:36:42PM -0400, Bo Liu wrote:
> As ida_simple_get() can fail, we should check the return value.
>
> Signed-off-by: Bo Liu <liubo03@xxxxxxxxxx>
> ---
> drivers/char/ppdev.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/char/ppdev.c b/drivers/char/ppdev.c
> index 38b46c7d1737..13b58b6823ee 100644
> --- a/drivers/char/ppdev.c
> +++ b/drivers/char/ppdev.c
> @@ -300,6 +300,11 @@ static int register_device(int minor, struct pp_struct *pp)
> }
>
> index = ida_simple_get(&ida_index, 0, 0, GFP_KERNEL);
> + if (index < 0) {
> + rc = index;
> + goto err;
> + }
> +
> memset(&ppdev_cb, 0, sizeof(ppdev_cb));
> ppdev_cb.irq_func = pp_irq;
> ppdev_cb.flags = (pp->flags & PP_EXCL) ? PARPORT_FLAG_EXCL : 0;
> --
> 2.27.0
>

You just leaked a memory reference here :(

How did you test this? What tool caused this to be changed? Please fix
up your tool to not add problems when it is attempting to fix problems,
as that's a never-ending cycle we do not want to be in :(

thanks,

greg k-h