Skip to contentSkip to conversation

HID: hyperv: NULL check before some freeing functions is not needed.

PATCH In review Lucas Tanure 4 participants 7 messages Feb 29, 2020 – Mar 4, 2020

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

PATCH 1/1 HID: hyperv: NULL check before some freeing functions is not needed.

Fix below warnings reported by coccicheck:
drivers/hid/hid-hyperv.c:197:2-7: WARNING: NULL check before some freeing functions is not needed. drivers/hid/hid-hyperv.c:211:2-7: WARNING: NULL check before some freeing functions is not needed.

---
 drivers/hid/hid-hyperv.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/hid/hid-hyperv.c +2 -4
index dddfca555df9..0b6ee1dee625 100644
@@ -193,8 +193,7 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device,
 		goto cleanup;
 
 	/* The pointer is not NULL when we resume from hibernation */
-	if (input_device->hid_desc != NULL)
-		kfree(input_device->hid_desc);
+	kfree(input_device->hid_desc);
 	input_device->hid_desc = kmemdup(desc, desc->bLength, GFP_ATOMIC);
 
 	if (!input_device->hid_desc)
@@ -207,8 +206,7 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device,
 	}
 
 	/* The pointer is not NULL when we resume from hibernation */
-	if (input_device->report_desc != NULL)
-		kfree(input_device->report_desc);
+	kfree(input_device->report_desc);
 	input_device->report_desc = kzalloc(input_device->report_desc_size,
 					  GFP_ATOMIC);
 
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw

From: Lucas Tanure <[email protected]> Sent: Saturday, February 29, 2020 9:30 AM

Quoted 8 lines

Fix below warnings reported by coccicheck:
drivers/hid/hid-hyperv.c:197:2-7: WARNING: NULL check before some freeing functions is not needed.
drivers/hid/hid-hyperv.c:211:2-7: WARNING: NULL check before some freeing functions is not needed.

Quoted 32 lines
---
 drivers/hid/hid-hyperv.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/hid/hid-hyperv.c +1 -2
index dddfca555df9..0b6ee1dee625 100644
@@ -193,8 +193,7 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev
 *input_device,
 		goto cleanup;
 
 	/* The pointer is not NULL when we resume from hibernation */
-	if (input_device->hid_desc != NULL)
-		kfree(input_device->hid_desc);
+	kfree(input_device->hid_desc);
 	input_device->hid_desc = kmemdup(desc, desc->bLength, GFP_ATOMIC);
 
drivers/hid/hid-hyperv.c +1 -3
 	if (!input_device->hid_desc)
@@ -207,8 +206,7 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev
 *input_device,
 	}
 
 	/* The pointer is not NULL when we resume from hibernation */
-	if (input_device->report_desc != NULL)
-		kfree(input_device->report_desc);
+	kfree(input_device->report_desc);
 	input_device->report_desc = kzalloc(input_device->report_desc_size,
 					  GFP_ATOMIC);
 
--

2.25.1

Acked-by on v1 1/1
#3 lore raw
In reply to Lucas Tanure
Quoted 7 lines · Lucas Tanure

Fix below warnings reported by coccicheck:
drivers/hid/hid-hyperv.c:197:2-7: WARNING: NULL check before some freeing functions is not needed. drivers/hid/hid-hyperv.c:211:2-7: WARNING: NULL check before some freeing functions is not needed.

---

Sasha, do you prefer taking this through your tree or through the HID one. I don't think we have much scheduled for hyperv, so it's up to you.

Cheers,
Benjamin

Quoted 30 lines
 drivers/hid/hid-hyperv.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/hid/hid-hyperv.c +2 -5
index dddfca555df9..0b6ee1dee625 100644
@@ -193,8 +193,7 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device,
                goto cleanup;
 
        /* The pointer is not NULL when we resume from hibernation */
-       if (input_device->hid_desc != NULL)
-               kfree(input_device->hid_desc);
+       kfree(input_device->hid_desc);
        input_device->hid_desc = kmemdup(desc, desc->bLength, GFP_ATOMIC);
 
        if (!input_device->hid_desc)
@@ -207,8 +206,7 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device,
        }
 
        /* The pointer is not NULL when we resume from hibernation */
-       if (input_device->report_desc != NULL)
-               kfree(input_device->report_desc);
+       kfree(input_device->report_desc);
        input_device->report_desc = kzalloc(input_device->report_desc_size,
                                          GFP_ATOMIC);
 
--

2.25.1

maintainer
#4 lore raw

Hi Benjamin

Quoted 6 lines · Benjamin Tissoires
Quoted 5 lines · Lucas Tanure

Fix below warnings reported by coccicheck:
drivers/hid/hid-hyperv.c:197:2-7: WARNING: NULL check before some freeing functions is not needed. drivers/hid/hid-hyperv.c:211:2-7: WARNING: NULL check before some freeing functions is not needed.

Quoted 8 lines
Quoted 2 lines

---

Sasha, do you prefer taking this through your tree or through the HID one. I don't think we have much scheduled for hyperv, so it's up to you.

Sasha stepped down as a hyperv maintainer a few days back. I will be taking over maintenance of the hyperv tree.

The problem is at the moment I haven't got write access to the repository hosted on git.kernel.org. That's something I will need to sort out as soon as possible.

In the meantime, it would be great if you can pick up this patch so that it doesn't get lost while I sort out access on my side.

Thanks,
Wei.

maintainer
#5 lore raw
Quoted 21 lines · Wei Liu

Hi Benjamin

Quoted 6 lines · Benjamin Tissoires
Quoted 5 lines · Lucas Tanure

Fix below warnings reported by coccicheck:
drivers/hid/hid-hyperv.c:197:2-7: WARNING: NULL check before some freeing functions is not needed. drivers/hid/hid-hyperv.c:211:2-7: WARNING: NULL check before some freeing functions is not needed.

Quoted 8 lines
Quoted 2 lines

---

Sasha, do you prefer taking this through your tree or through the HID one. I don't think we have much scheduled for hyperv, so it's up to you.

Sasha stepped down as a hyperv maintainer a few days back. I will be taking over maintenance of the hyperv tree.

Quoted 6 lines

The problem is at the moment I haven't got write access to the repository hosted on git.kernel.org. That's something I will need to sort out as soon as possible.

In the meantime, it would be great if you can pick up this patch so that it doesn't get lost while I sort out access on my side.

Hi Benjamin

I got access to the Hyper-V tree. I will be picking this patch up since I haven't got a confirmation from your side.

Wei.

Quoted 3 lines

Thanks,
Wei.

#6 lore raw
Quoted 27 lines · Wei Liu
Quoted 25 lines · Wei Liu

Hi Benjamin

Quoted 6 lines · Benjamin Tissoires
Quoted 5 lines · Lucas Tanure

Fix below warnings reported by coccicheck:
drivers/hid/hid-hyperv.c:197:2-7: WARNING: NULL check before some freeing functions is not needed. drivers/hid/hid-hyperv.c:211:2-7: WARNING: NULL check before some freeing functions is not needed.

Quoted 8 lines
Quoted 2 lines

---

Sasha, do you prefer taking this through your tree or through the HID one. I don't think we have much scheduled for hyperv, so it's up to you.

Sasha stepped down as a hyperv maintainer a few days back. I will be taking over maintenance of the hyperv tree.

The problem is at the moment I haven't got write access to the repository hosted on git.kernel.org. That's something I will need to sort out as soon as possible.

Quoted 8 lines
Quoted 2 lines

In the meantime, it would be great if you can pick up this patch so that it doesn't get lost while I sort out access on my side.

Hi Benjamin

I got access to the Hyper-V tree. I will be picking this patch up since I haven't got a confirmation from your side.

Great, thanks.

Sorry, I am pulled in freedesktop tasks right now that are a little bit urgent.

Glad you quickly set up the access rights.

Cheers,
Benjamin