Skip to contentSkip to conversation

rfkill: Fix check for correct rfkill allocation

PATCH In review Ivo van Doorn 2 participants 2 messages May 19, 2007

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

PATCH 1/1 rfkill: Fix check for correct rfkill allocation

coverity has spotted a bug in rfkill.c (bug id #1627), in rfkill_allocate() NULL was returns if the kzalloc() works, and deref the NULL pointer if it fails,

---

net/rfkill/rfkill.c +1 -1
index a973603..f3986d4 100644
@@ -296,7 +296,7 @@ struct rfkill *rfkill_allocate(struct device *parent, enum rfkill_type type)
 	struct device *dev;
 
 	rfkill = kzalloc(sizeof(struct rfkill), GFP_KERNEL);
-	if (rfkill)
+	if (!rfkill)
 		return NULL;
 
 	mutex_init(&rfkill->mutex);
maintainer
#1 lore raw

From: Ivo van Doorn <[email protected]>
Date: Sat, 19 May 2007 14:08:43 +0200

Quoted 5 lines

coverity has spotted a bug in rfkill.c (bug id #1627), in rfkill_allocate() NULL was returns if the kzalloc() works, and deref the NULL pointer if it fails,

I really wonder how well tested this rfkill code is if the object allocation is so busted like this :-/

I'll apply your patch, thank you.