linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][next] afs: fix double kfree on cell_name on error exit path
@ 2020-06-02 15:35 Colin King
  2020-06-02 15:57 ` David Howells
  0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2020-06-02 15:35 UTC (permalink / raw)
  To: David Howells, linux-afs, linux-kernel; +Cc: kernel-janitors

From: Colin Ian King <colin.king@canonical.com>

The error exit path is currently kfree'ing cell_name for a second time,
the previous kfree of this object occurred a statement earlier. Fix this
by removing it.

Addresses-Coverity: ("Double free")
Fixes: 6147fe6b7f8c ("afs: Detect cell aliases 3 - YFS Cells with a canonical cell name op")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 fs/afs/vl_alias.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/fs/afs/vl_alias.c b/fs/afs/vl_alias.c
index 6c1cf702478e..093895c49c21 100644
--- a/fs/afs/vl_alias.c
+++ b/fs/afs/vl_alias.c
@@ -315,10 +315,8 @@ static int yfs_check_canonical_cell_name(struct afs_cell *cell, struct key *key)
 	master = afs_lookup_cell(cell->net, cell_name, strlen(cell_name),
 				 NULL, false);
 	kfree(cell_name);
-	if (IS_ERR(master)) {
-		kfree(cell_name);
+	if (IS_ERR(master))
 		return PTR_ERR(master);
-	}
 
 	cell->alias_of = master; /* Transfer our ref */
 	return 1;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH][next] afs: fix double kfree on cell_name on error exit path
  2020-06-02 15:35 [PATCH][next] afs: fix double kfree on cell_name on error exit path Colin King
@ 2020-06-02 15:57 ` David Howells
  0 siblings, 0 replies; 2+ messages in thread
From: David Howells @ 2020-06-02 15:57 UTC (permalink / raw)
  To: Colin King; +Cc: dhowells, linux-afs, linux-kernel, kernel-janitors

Colin King <colin.king@canonical.com> wrote:

> From: Colin Ian King <colin.king@canonical.com>
> 
> The error exit path is currently kfree'ing cell_name for a second time,
> the previous kfree of this object occurred a statement earlier. Fix this
> by removing it.
> 
> Addresses-Coverity: ("Double free")
> Fixes: 6147fe6b7f8c ("afs: Detect cell aliases 3 - YFS Cells with a canonical cell name op")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

I've folded it in, thanks.

David


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-06-02 15:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-02 15:35 [PATCH][next] afs: fix double kfree on cell_name on error exit path Colin King
2020-06-02 15:57 ` David Howells

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).