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