[PATCH] ppdev: check ida_simple_get() return value

From: Bo Liu
Date: Tue Sep 06 2022 - 22:37:39 EST


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