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

From: Fabio M. De Francesco
Date: Fri Jun 04 2021 - 22:09:55 EST


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.

Signed-off-by: Fabio M. De Francesco <fmdefrancesco@xxxxxxxxx>
Acked-by: Sakari Ailus <sakari.ailus@xxxxxxxxxxxxxxx>
---

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(-)

diff --git a/drivers/staging/media/atomisp/pci/sh_css_firmware.c b/drivers/staging/media/atomisp/pci/sh_css_firmware.c
index f4ce8ace9d50..5301cc014c7e 100644
--- a/drivers/staging/media/atomisp/pci/sh_css_firmware.c
+++ b/drivers/staging/media/atomisp/pci/sh_css_firmware.c
@@ -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;
--
2.31.1