* [PATCH] smb3: Improve exception handling in allocate_mr_list()
@ 2023-12-30 9:47 Markus Elfring
2024-01-05 19:57 ` Steve French
0 siblings, 1 reply; 2+ messages in thread
From: Markus Elfring @ 2023-12-30 9:47 UTC (permalink / raw)
To: linux-cifs, samba-technical, kernel-janitors, Paulo Alcantara,
Ronnie Sahlberg, Shyam Prasad N, Steve French, Tom Talpey
Cc: LKML
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 29 Dec 2023 20:43:12 +0100
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>
---
fs/smb/client/smbdirect.c | 4 ++--
1 file 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);
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] smb3: Improve exception handling in allocate_mr_list()
2023-12-30 9:47 [PATCH] smb3: Improve exception handling in allocate_mr_list() Markus Elfring
@ 2024-01-05 19:57 ` Steve French
0 siblings, 0 replies; 2+ messages in thread
From: Steve French @ 2024-01-05 19:57 UTC (permalink / raw)
To: Markus Elfring
Cc: linux-cifs, samba-technical, kernel-janitors, Paulo Alcantara,
Ronnie Sahlberg, Shyam Prasad N, Steve French, Tom Talpey, LKML
merged into cifs-2.6.git for-next
On Sat, Dec 30, 2023 at 3:47 AM Markus Elfring <Markus.Elfring@web.de> wrote:
>
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 29 Dec 2023 20:43:12 +0100
>
> 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>
> ---
> fs/smb/client/smbdirect.c | 4 ++--
> 1 file 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);
> --
> 2.43.0
>
>
--
Thanks,
Steve
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-01-05 19:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-30 9:47 [PATCH] smb3: Improve exception handling in allocate_mr_list() Markus Elfring
2024-01-05 19:57 ` Steve French
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).