Skip to contentSkip to conversation

Remove unnecessary tests and cast before kfree/kvfree

PATCH In review Fabio M. De Francesco 2 participants 5 messages Jun 5, 2021 – Jun 14, 2021

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

v2 cover Remove unnecessary tests and cast before kfree/kvfree

(1/2) Removed unnecessary test of pointers != NULL before passing them to kfree() and kvfree().
(2/2) Removed an unncecessary (void *) cast for an argument passed to kfree().

v1 -> v2: Added patch 2/2.

Fabio M. De Francesco (2):
staging: media: atomisp: pci: Remove checks before kfree/kvfree
staging: media: atomisp: pci: Remove unnecessary (void *) cast

 drivers/staging/media/atomisp/pci/sh_css_firmware.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
Signature · 1 line
2.31.1
#1 lore raw

PATCH v2 1/2 staging: media: atomisp: pci: Remove checks before kfree/kvfree

Removed checks for pointers != NULL before freeing memory. If kvfree() and kfree() are given NULL pointers no operations are performed, so there is no need for the above-mentioned checks. Coccinelle detected the second of the two unnecessary checks.

---

v1 -> v2: Added Acked-by Sakari Alius. No changes in code.

 drivers/staging/media/atomisp/pci/sh_css_firmware.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/staging/media/atomisp/pci/sh_css_firmware.c +2 -4
index f4ce8ace9d50..5301cc014c7e 100644
@@ -363,10 +363,8 @@ void sh_css_unload_firmware(void)
 		unsigned int i = 0;
 
 		for (i = 0; i < sh_css_num_binaries; i++) {
-			if (fw_minibuffer[i].name)
-				kfree((void *)fw_minibuffer[i].name);
-			if (fw_minibuffer[i].buffer)
-				kvfree(fw_minibuffer[i].buffer);
+			kfree((void *)fw_minibuffer[i].name);
+			kvfree(fw_minibuffer[i].buffer);
 		}
 		kfree(fw_minibuffer);
 		fw_minibuffer = NULL;
Signature · 1 line
2.31.1
#2 lore raw

PATCH v2 2/2 staging: media: atomisp: pci: Remove unnecessary (void *) cast

In reply to Fabio M. De Francesco

Removed an unnecessary (void *) cast for an argument passed to kfree().

---

v1 -> v2: Added this 2/2 patch.

 drivers/staging/media/atomisp/pci/sh_css_firmware.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/media/atomisp/pci/sh_css_firmware.c +1 -1
index 5301cc014c7e..e1a16a50e588 100644
@@ -363,7 +363,7 @@ void sh_css_unload_firmware(void)
 		unsigned int i = 0;
 
 		for (i = 0; i < sh_css_num_binaries; i++) {
-			kfree((void *)fw_minibuffer[i].name);
+			kfree(fw_minibuffer[i].name);
 			kvfree(fw_minibuffer[i].buffer);
 		}
 		kfree(fw_minibuffer);
Signature · 1 line
2.31.1
#3 lore raw
In reply to Fabio M. De Francesco

Hi All,

I've seen that some patches of mine, more recent the following ones, have already been applied. In the past I had noticed that the patches are (usually?) placed in a time of submission ordered FIFO, unless they are rejected.

I'm wondering if I should re-send them or if I am missing some details about the specific workflow of staging/media.

Thanks,

Fabio

Quoted 3 lines · CEST Fabio M. De Francesco

(1/2) Removed unnecessary test of pointers != NULL before passing them to kfree() and kvfree().
(2/2) Removed an unnecessary (void *) cast for an argument passed to

kfree().

Quoted 9 lines

v1 -> v2: Added patch 2/2.

Fabio M. De Francesco (2):
staging: media: atomisp: pci: Remove checks before kfree/kvfree
staging: media: atomisp: pci: Remove unnecessary (void *) cast

 drivers/staging/media/atomisp/pci/sh_css_firmware.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
#4 lore raw

Em Mon, 14 Jun 2021 18:33:55 +0200
"Fabio M. De Francesco" <[email protected]> escreveu:

Quoted 9 lines

Hi All,

I've seen that some patches of mine, more recent the following ones, have already been applied. In the past I had noticed that the patches are (usually?) placed in a time of submission ordered FIFO, unless they are rejected.

I'm wondering if I should re-send them or if I am missing some details about the specific workflow of staging/media.

Any patches sent to [email protected] are automatically stored at patchwork:

https://patchwork.linuxtv.org/project/linux-media/list/

If the patches you sent are there and are marked with "New" state, there's no need to re-submit. On a quick check, there are 3 media patches from you there:

https://patchwork.linuxtv.org/project/linux-media/list/?series=&submitter=8492&state=&q=&archive=&delegate=

No need to resubmit those, except if some reviewer asks you to change your patch(es).

Thanks,
Mauro