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

Bill Pemberton wfp5p at virginia.edu
Mon May 3 21:50:43 UTC 2010


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 at virginia.edu>
---
 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




More information about the devel mailing list