Skip to content

Commit 96d566b

Browse files
elfringsmfrench
authored andcommitted
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 <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 516eea9 commit 96d566b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/smb/client/smbdirect.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2136,7 +2136,7 @@ static int allocate_mr_list(struct smbd_connection *info)
21362136
for (i = 0; i < info->responder_resources * 2; i++) {
21372137
smbdirect_mr = kzalloc(sizeof(*smbdirect_mr), GFP_KERNEL);
21382138
if (!smbdirect_mr)
2139-
goto out;
2139+
goto cleanup_entries;
21402140
smbdirect_mr->mr = ib_alloc_mr(info->pd, info->mr_type,
21412141
info->max_frmr_depth);
21422142
if (IS_ERR(smbdirect_mr->mr)) {
@@ -2162,7 +2162,7 @@ static int allocate_mr_list(struct smbd_connection *info)
21622162

21632163
out:
21642164
kfree(smbdirect_mr);
2165-
2165+
cleanup_entries:
21662166
list_for_each_entry_safe(smbdirect_mr, tmp, &info->mr_list, list) {
21672167
list_del(&smbdirect_mr->list);
21682168
ib_dereg_mr(smbdirect_mr->mr);

0 commit comments

Comments
 (0)