Skip to contentSkip to conversation

HID: appleir: Remove unnecessary goto label

PATCH Applied Lucas Tanure 2 participants 3 messages Feb 29, 2020 – Mar 13, 2020 HID

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 HID: appleir: Remove unnecessary goto label

---
 drivers/hid/hid-appleir.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/hid/hid-appleir.c +2 -5
index bf8d4afe0d6a..aafc285b538f 100644
@@ -284,10 +284,8 @@ static int appleir_probe(struct hid_device *hid, const struct hid_device_id *id)
 	struct appleir *appleir;
 
 	appleir = kzalloc(sizeof(struct appleir), GFP_KERNEL);
-	if (!appleir) {
-		ret = -ENOMEM;
-		goto allocfail;
-	}
+	if (!appleir)
+		return -ENOMEM;
 
 	appleir->hid = hid;
 
@@ -314,7 +312,6 @@ static int appleir_probe(struct hid_device *hid, const struct hid_device_id *id)
 	return 0;
 fail:
 	kfree(appleir);
-allocfail:
 	return ret;
 }
 
Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/2 HID: appleir: Use devm_kzalloc() instead of kzalloc()

---
 drivers/hid/hid-appleir.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/hid/hid-appleir.c +2 -3
index aafc285b538f..8deded185725 100644
@@ -283,7 +283,7 @@ static int appleir_probe(struct hid_device *hid, const struct hid_device_id *id)
 	int ret;
 	struct appleir *appleir;
 
-	appleir = kzalloc(sizeof(struct appleir), GFP_KERNEL);
+	appleir = devm_kzalloc(&hid->dev, sizeof(struct appleir), GFP_KERNEL);
 	if (!appleir)
 		return -ENOMEM;
 
@@ -311,7 +311,7 @@ static int appleir_probe(struct hid_device *hid, const struct hid_device_id *id)
 
 	return 0;
 fail:
-	kfree(appleir);
+	devm_kfree(&hid->dev, appleir);
 	return ret;
 }
 
@@ -320,7 +320,6 @@ static void appleir_remove(struct hid_device *hid)
 	struct appleir *appleir = hid_get_drvdata(hid);
 	hid_hw_stop(hid);
 	del_timer_sync(&appleir->key_up_timer);
-	kfree(appleir);
 }
 
 static const struct hid_device_id appleir_devices[] = {
Signature · 1 line
2.25.1
maintainer Applied
#2 lore raw
In reply to Lucas Tanure
Quoted 23 lines · Lucas Tanure
---
 drivers/hid/hid-appleir.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/hid/hid-appleir.c +2 -4
index bf8d4afe0d6a..aafc285b538f 100644
@@ -284,10 +284,8 @@ static int appleir_probe(struct hid_device *hid, const struct hid_device_id *id)
 	struct appleir *appleir;
 
 	appleir = kzalloc(sizeof(struct appleir), GFP_KERNEL);
-	if (!appleir) {
-		ret = -ENOMEM;
-		goto allocfail;
-	}
+	if (!appleir)
+		return -ENOMEM;
 
 	appleir->hid = hid;
 

drivers/hid/hid-appleir.c static int appleir_probe(struct hid_device *hid, const struct hid_device_id *id) · line 316

Quoted 6 lines
drivers/hid/hid-appleir.c +0 -1
@@ -314,7 +312,6 @@ static int appleir_probe(struct hid_device *hid, const struct hid_device_id *id)
 	return 0;
 fail:
 	kfree(appleir);
-allocfail:
 	return ret;
 }

Applied, thanks.

Signature · 2 lines
Jiri Kosina
SUSE Labs