From: Greg KH <gregkh@linuxfoundation.org>
To: Bo Liu <liubo03@inspur.com>
Cc: sudipm.mukherjee@gmail.com, arnd@arndb.de, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ppdev: check ida_simple_get() return value
Date: Fri, 9 Sep 2022 10:08:11 +0200 [thread overview]
Message-ID: <Yxr0a3fnLUsPnyJL@kroah.com> (raw)
In-Reply-To: <20220907023642.2333-1-liubo03@inspur.com>
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@inspur.com>
> ---
> 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
prev parent reply other threads:[~2022-09-09 8:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-07 2:36 Bo Liu
2022-09-09 8:08 ` Greg KH [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Yxr0a3fnLUsPnyJL@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=arnd@arndb.de \
--cc=linux-kernel@vger.kernel.org \
--cc=liubo03@inspur.com \
--cc=sudipm.mukherjee@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®