ppdev: check ida_simple_get() return value
Subsystems (2)
PATCH 1/1 ppdev: check ida_simple_get() return value
As ida_simple_get() can fail, we should check the return value.
Signed-off-by Bo Liu <[email protected]>
--- drivers/char/ppdev.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/char/ppdev.c +5 -0
@@ -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 ;
Signature · 1 line
2.27.0
Greg KH
maintainerQuoted 26 lines · Bo Liu
As
ida_simple_get()can fail, we should check the return value.Signed-off-by Bo Liu <[email protected]>--- drivers/char/ppdev.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/char/ppdev.c +5
-0@@ -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 ;Signature · 1 line
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