[PATCH 13/19] include <linux/idr.h>: handle OOM gracefully inside idr_alloc_one

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The result of allocating a struct idr is dereferenced unconditionally.
Return -ENOMEM in that case instead.

Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
---
 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





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux