Skip to contentSkip to conversation

ecryptfs: ecryptfs_msg_ctx_alloc_to_free(): remove kfree() redundant null check

PATCH In review Tim Gardner 2 participants 2 messages Feb 12, 2013 Ecrypt file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ecryptfs: ecryptfs_msg_ctx_alloc_to_free(): remove kfree() redundant null check

smatch analysis:

fs/ecryptfs/messaging.c:101 ecryptfs_msg_ctx_alloc_to_free() info:
redundant null check on msg_ctx->msg calling kfree()

---
 fs/ecryptfs/messaging.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/ecryptfs/messaging.c +1 -2
index 8d7a577..308fdf2 100644
@@ -97,8 +97,7 @@ static void ecryptfs_msg_ctx_free_to_alloc(struct ecryptfs_msg_ctx *msg_ctx)
 void ecryptfs_msg_ctx_alloc_to_free(struct ecryptfs_msg_ctx *msg_ctx)
 {
 	list_move(&(msg_ctx->node), &ecryptfs_msg_ctx_free_list);
-	if (msg_ctx->msg)
-		kfree(msg_ctx->msg);
+	kfree(msg_ctx->msg);
 	msg_ctx->msg = NULL;
 	msg_ctx->state = ECRYPTFS_MSG_CTX_STATE_FREE;
 }
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 9 lines · Tim Gardner

smatch analysis:

fs/ecryptfs/messaging.c:101 ecryptfs_msg_ctx_alloc_to_free() info:
redundant null check on msg_ctx->msg calling kfree()

Thanks, Tim. Pushed to the next branch at
git://git.kernel.org/pub/scm/linux/kernel/git/tyhicks/ecryptfs.git

Tyler

Quoted 21 lines
---
 fs/ecryptfs/messaging.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/ecryptfs/messaging.c +1 -2
index 8d7a577..308fdf2 100644
@@ -97,8 +97,7 @@ static void ecryptfs_msg_ctx_free_to_alloc(struct ecryptfs_msg_ctx *msg_ctx)
 void ecryptfs_msg_ctx_alloc_to_free(struct ecryptfs_msg_ctx *msg_ctx)
 {
 	list_move(&(msg_ctx->node), &ecryptfs_msg_ctx_free_list);
-	if (msg_ctx->msg)
-		kfree(msg_ctx->msg);
+	kfree(msg_ctx->msg);
 	msg_ctx->msg = NULL;
 	msg_ctx->state = ECRYPTFS_MSG_CTX_STATE_FREE;
 }
Signature · 1 line
1.7.9.5