* [PATCH] ppdev: check ida_simple_get() return value
@ 2022-09-07 2:36 Bo Liu
2022-09-09 8:08 ` Greg KH
0 siblings, 1 reply; 2+ messages in thread
From: Bo Liu @ 2022-09-07 2:36 UTC (permalink / raw)
To: sudipm.mukherjee, arnd, gregkh; +Cc: linux-kernel, Bo Liu
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ppdev: check ida_simple_get() return value
2022-09-07 2:36 [PATCH] ppdev: check ida_simple_get() return value Bo Liu
@ 2022-09-09 8:08 ` Greg KH
0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2022-09-09 8:08 UTC (permalink / raw)
To: Bo Liu; +Cc: sudipm.mukherjee, arnd, linux-kernel
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-09-09 8:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-07 2:36 [PATCH] ppdev: check ida_simple_get() return value Bo Liu
2022-09-09 8:08 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).