Skip to contentSkip to conversation

fb: handle allocation failure in alloc_apertures()

PATCH In review Dan Carpenter 3 participants 3 messages Jul 15, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fb: handle allocation failure in alloc_apertures()

If the kzalloc() fails we should return NULL. All the places that call alloc_apertures() check for this already.

include/linux/fb.h +2 -0
index 8e5a9df..e7445df 100644
@@ -873,6 +873,8 @@ struct fb_info {
 static inline struct apertures_struct *alloc_apertures(unsigned int max_num) {
 	struct apertures_struct *a = kzalloc(sizeof(struct apertures_struct)
 			+ max_num * sizeof(struct aperture), GFP_KERNEL);
+	if (!a)
+		return NULL;
 	a->count = max_num;
 	return a;
 }
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines

If the kzalloc() fails we should return NULL. All the places that call alloc_apertures() check for this already.

Quoted 19 lines
include/linux/fb.h +2 -1
index 8e5a9df..e7445df 100644
@@ -873,6 +873,8 @@ struct fb_info {
 static inline struct apertures_struct *alloc_apertures(unsigned int max_num) {
 	struct apertures_struct *a = kzalloc(sizeof(struct apertures_struct)
 			+ max_num * sizeof(struct aperture), GFP_KERNEL);
+	if (!a)
+		return NULL;
 	a->count = max_num;
 	return a;
 }
 
--

To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Acked-by on v1 1/1
#2 lore raw
In reply to Dan Carpenter
Quoted 2 lines · Dan Carpenter

If the kzalloc() fails we should return NULL. All the places that call alloc_apertures() check for this already.

Thanks for fixing this. I added this function, so FWIW:

Quoted 16 lines
include/linux/fb.h +2 -0
index 8e5a9df..e7445df 100644
@@ -873,6 +873,8 @@ struct fb_info {
 static inline struct apertures_struct *alloc_apertures(unsigned int max_num) {
 	struct apertures_struct *a = kzalloc(sizeof(struct apertures_struct)
 			+ max_num * sizeof(struct aperture), GFP_KERNEL);
+	if (!a)
+		return NULL;
 	a->count = max_num;
 	return a;
 }