[PATCH 13/19] include <linux/idr.h>: handle OOM gracefully inside idr_alloc_one
Ahmad Fatoum
a.fatoum at pengutronix.de
Mon Jun 12 06:02:34 PDT 2023
The result of allocating a struct idr is dereferenced unconditionally.
Return -ENOMEM in that case instead.
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
include/linux/idr.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/include/linux/idr.h b/include/linux/idr.h
index 50c9e3f81ade..12494b1f01cb 100644
--- a/include/linux/idr.h
+++ b/include/linux/idr.h
@@ -54,6 +54,8 @@ static inline int idr_alloc_one(struct idr *head, void *ptr, int start)
return -EBUSY;
idr = malloc(sizeof(*idr));
+ if (!idr)
+ return -ENOMEM;
idr->id = start;
idr->ptr = ptr;
--
2.39.2
More information about the barebox
mailing list