HID: kfree() NULL pointer cleanup
Subsystems (2)
PATCH v2 1/2 HID: kfree() NULL pointer cleanup
Checking for NULL pointers before kfree() is redundant. v2:
No need for freeing pm in case when it's not allocated.
Reported-by Julia Lawall <[email protected]>
Signed-off-by Bojan Prtvar <[email protected]>
--- drivers/hid/hid-prodikeys.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
drivers/hid/hid-prodikeys.c +4 -4
@@ -816,7 +816,7 @@ static int pk_probe(struct hid_device *hdev, const struct hid_device_id *id)if (pm =NULL ) {hid_err (hdev,"can't alloc descriptor\n" ); ret = -ENOMEM ; - goto err_free; + goto err_free_pk; } pm->pk = pk;
@@ -849,10 +849,10 @@ static int pk_probe(struct hid_device *hdev, const struct hid_device_id *id) err_stop:hid_hw_stop (hdev); err_free: -if (pm !=NULL ) -kfree (pm); - +kfree (pm); +err_free_pk:kfree (pk); +return ret; }
Signature · 1 line
1.7.1
Jiri Kosina
AppliedQuoted 27 lines · Bojan Prtvar
Checking for NULL pointers before
kfree()is redundant. v2:
No need for freeing pm in case when it's not allocated.Reported-by Julia Lawall <[email protected]>Signed-off-by Bojan Prtvar <[email protected]>--- drivers/hid/hid-prodikeys.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)drivers/hid/hid-prodikeys.c +1
-1@@ -816,7 +816,7 @@ static int pk_probe(struct hid_device *hdev, const struct hid_device_id *id)if (pm =NULL ) {hid_err (hdev,"can't alloc descriptor\n" ); ret = -ENOMEM ; - goto err_free; + goto err_free_pk; } pm->pk = pk;@@ -849,10 +849,10 @@ static int pk_probe(struct hid_device *hdev, const struct hid_device_id *id) err_stop:hid_hw_stop (hdev); err_free:
drivers/hid/hid-prodikeys.c static int pk_probe(struct hid_device *hdev, const struct hid_device_id *id) · line 858
Quoted 10 lines
drivers/hid/hid-prodikeys.c +3
-3-if (pm !=NULL ) -kfree (pm); - +kfree (pm); +err_free_pk:kfree (pk); +return ret; }
Applied, thanks to both.
Signature · 2 lines
Jiri Kosina SUSE Labs