summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Elfring <elfring@users.sourceforge.net>2023-12-29 20:43:12 +0100
committerSteve French <stfrench@microsoft.com>2024-01-07 15:46:06 -0600
commit96d566b6c933be96e9f5b216f04024ab522e0465 (patch)
tree2de5a8c4792ef5e1137760b420498df83e7475a4
parent516eea97f92f1e7271f20835cfe9e73774b0f8cc (diff)
downloadlinux-stable-96d566b6c933be96e9f5b216f04024ab522e0465.tar.gz
linux-stable-96d566b6c933be96e9f5b216f04024ab522e0465.tar.bz2
linux-stable-96d566b6c933be96e9f5b216f04024ab522e0465.zip
smb3: Improve exception handling in allocate_mr_list()
The kfree() function was called in one case by the allocate_mr_list() function during error handling even if the passed variable contained a null pointer. This issue was detected by using the Coccinelle software. Thus use another label. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Signed-off-by: Steve French <stfrench@microsoft.com>
-rw-r--r--fs/smb/client/smbdirect.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/fs/smb/client/smbdirect.c b/fs/smb/client/smbdirect.c
index 94df9eec3d8d..d74e829de51c 100644
--- a/fs/smb/client/smbdirect.c
+++ b/fs/smb/client/smbdirect.c
@@ -2136,7 +2136,7 @@ static int allocate_mr_list(struct smbd_connection *info)
for (i = 0; i < info->responder_resources * 2; i++) {
smbdirect_mr = kzalloc(sizeof(*smbdirect_mr), GFP_KERNEL);
if (!smbdirect_mr)
- goto out;
+ goto cleanup_entries;
smbdirect_mr->mr = ib_alloc_mr(info->pd, info->mr_type,
info->max_frmr_depth);
if (IS_ERR(smbdirect_mr->mr)) {
@@ -2162,7 +2162,7 @@ static int allocate_mr_list(struct smbd_connection *info)
out:
kfree(smbdirect_mr);
-
+cleanup_entries:
list_for_each_entry_safe(smbdirect_mr, tmp, &info->mr_list, list) {
list_del(&smbdirect_mr->list);
ib_dereg_mr(smbdirect_mr->mr);