Skip to contentSkip to conversation

HID: kfree() NULL pointer cleanup

PATCH Applied Bojan Prtvar 2 participants 2 messages Aug 4, 2011

Subsystems (2)

v1 of 2 Applied Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 HID: kfree() NULL pointer cleanup

Checking for NULL pointers before kfree() is redundant.

---
 drivers/hid/hid-zydacron.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)
drivers/hid/hid-zydacron.c +1 -3
index e903715..1ad85f2 100644
@@ -201,9 +201,7 @@ static void zc_remove(struct hid_device *hdev)
 	struct zc_device *zc = hid_get_drvdata(hdev);
 
 	hid_hw_stop(hdev);
-
-	if (NULL != zc)
-		kfree(zc);
+	kfree(zc);
 }
 
 static const struct hid_device_id zc_devices[] = {
Signature · 1 line
1.7.1
Applied
#1 lore raw
Quoted 12 lines · Bojan Prtvar

Checking for NULL pointers before kfree() is redundant.

---
 drivers/hid/hid-zydacron.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)
drivers/hid/hid-zydacron.c +0 -0
index e903715..1ad85f2 100644

drivers/hid/hid-zydacron.c static void zc_remove(struct hid_device *hdev) · line 205

Quoted 8 lines
drivers/hid/hid-zydacron.c +1 -3
@@ -201,9 +201,7 @@ static void zc_remove(struct hid_device *hdev)
 	struct zc_device *zc = hid_get_drvdata(hdev);
 
 	hid_hw_stop(hdev);
-
-	if (NULL != zc)
-		kfree(zc);
+	kfree(zc);
 }

Applied, thanks.

Signature · 2 lines
Jiri Kosina
SUSE Labs