[PATCH][next] afs: fix double kfree on cell_name on error exit path

From: Colin King
Date: Tue Jun 02 2020 - 11:35:11 EST


From: Colin Ian King <colin.king@xxxxxxxxxxxxx>

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@xxxxxxxxxxxxx>
---
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