Skip to contentSkip to conversation

cifs: Fix a tiny potential memory leak

PATCH Applied Dan Carpenter 2 participants 2 messages Jan 5, 2019 Kernel janitors

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cifs: Fix a tiny potential memory leak

The most recent "it" allocation is leaked on this error path. I believe that small allocations always succeed in current kernels so this doesn't really affect run time.

Fixes 54be1f6c1c37 ("cifs: Add DFS cache routines")
---
 fs/cifs/dfs_cache.c | 1 +
 1 file changed, 1 insertion(+)
fs/cifs/dfs_cache.c +1 -0
index cd63c4a70875..09b7d0d4f6e4 100644
@@ -776,6 +776,7 @@ static int get_tgt_list(const struct dfs_cache_entry *ce,
 		it->it_name = kstrndup(t->t_name, strlen(t->t_name),
 				       GFP_KERNEL);
 		if (!it->it_name) {
+			kfree(it);
 			rc = -ENOMEM;
 			goto err_free_it;
 		}

--
2.17.1

Applied
#1 lore raw

merged into cifs-2.6.git for-next

thx

Quoted 26 lines · Dan Carpenter via samba-technical

The most recent "it" allocation is leaked on this error path. I believe that small allocations always succeed in current kernels so this doesn't really affect run time.

Fixes 54be1f6c1c37 ("cifs: Add DFS cache routines")
---
 fs/cifs/dfs_cache.c | 1 +
 1 file changed, 1 insertion(+)
fs/cifs/dfs_cache.c +1 -1
index cd63c4a70875..09b7d0d4f6e4 100644
@@ -776,6 +776,7 @@ static int get_tgt_list(const struct dfs_cache_entry *ce,
                it->it_name = kstrndup(t->t_name, strlen(t->t_name),
                                       GFP_KERNEL);
                if (!it->it_name) {
+                       kfree(it);
                        rc = -ENOMEM;
                        goto err_free_it;
                }
--

2.17.1

Signature · 3 lines
Thanks,

Steve