Skip to content

Commit

Permalink
smb3: Improve exception handling in allocate_mr_list()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Markus Elfring authored and Steve French committed Jan 7, 2024
1 parent 516eea9 commit 96d566b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fs/smb/client/smbdirect.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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);
Expand Down

0 comments on commit 96d566b

Please sign in to comment.