[PATCH 1/3] Staging: hv: Remove checks for NULL before calling kfree()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



kfree() knows how to deal with NULL, so there's no reason to check for
NULL before passing something to it.

Signed-off-by: Bill Pemberton <wfp5p@xxxxxxxxxxxx>
---
 drivers/staging/hv/ChannelMgmt.c |    6 ++----
 drivers/staging/hv/Hv.c          |   10 +++++-----
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/hv/ChannelMgmt.c b/drivers/staging/hv/ChannelMgmt.c
index 43f28f2..8d5f305 100644
--- a/drivers/staging/hv/ChannelMgmt.c
+++ b/drivers/staging/hv/ChannelMgmt.c
@@ -642,10 +642,8 @@ int VmbusChannelRequestOffers(void)
 
 
 Cleanup:
-	if (msgInfo) {
-		kfree(msgInfo->WaitEvent);
-		kfree(msgInfo);
-	}
+	kfree(msgInfo->WaitEvent);
+	kfree(msgInfo);
 
 	DPRINT_EXIT(VMBUS);
 	return ret;
diff --git a/drivers/staging/hv/Hv.c b/drivers/staging/hv/Hv.c
index 62debf8..2e2222d 100644
--- a/drivers/staging/hv/Hv.c
+++ b/drivers/staging/hv/Hv.c
@@ -305,11 +305,11 @@ void HvCleanup(void)
 
 	DPRINT_ENTER(VMBUS);
 
-	if (gHvContext.SignalEventBuffer) {
-		kfree(gHvContext.SignalEventBuffer);
-		gHvContext.SignalEventBuffer = NULL;
-		gHvContext.SignalEventParam = NULL;
-	}
+
+	kfree(gHvContext.SignalEventBuffer);
+	gHvContext.SignalEventBuffer = NULL;
+	gHvContext.SignalEventParam = NULL;
+
 
 	if (gHvContext.HypercallPage) {
 		hypercallMsr.AsUINT64 = 0;
-- 
1.7.1

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel

[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux