cifs: Fix a tiny potential memory leak
authorDan Carpenter <dan.carpenter@oracle.com>
Sat, 5 Jan 2019 18:18:03 +0000 (21:18 +0300)
committerSteve French <stfrench@microsoft.com>
Thu, 10 Jan 2019 20:32:30 +0000 (14:32 -0600)
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")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/cifs/dfs_cache.c

index cd63c4a70875fdb4bace5e0be81551c41394071e..09b7d0d4f6e4fe5f6708d6387f6507ee20f6482f 100644 (file)
@@ -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;
                }