From: Markus Elfring <Markus.Elfring@web.de>
To: Michael Kelley <mhklinux@outlook.com>,
linux-hyperv@vger.kernel.org, kernel-janitors@vger.kernel.org,
Dexuan Cui <decui@microsoft.com>,
Haiyang Zhang <haiyangz@microsoft.com>,
"K. Y. Srinivasan" <kys@microsoft.com>,
Wei Liu <wei.liu@kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>, "cocci@inria.fr" <cocci@inria.fr>
Subject: Re: Drivers: hv: vmbus: One function call less in create_gpadl_header() after error detection
Date: Wed, 10 Jan 2024 18:08:17 +0100 [thread overview]
Message-ID: <1910913d-c3fe-45ab-a871-deda5318e2cf@web.de> (raw)
In-Reply-To: <SN6PR02MB4157CA3901DD8D069C755C72D4692@SN6PR02MB4157.namprd02.prod.outlook.com>
> It occurred to me overnight that the existing error handling
> in create_gpadl_header() is unnecessarily complicated. Here's
> an approach that I think would fix what you have flagged, and
> would reduce complexity instead of increasing it. Thoughts?
I find this development view interesting.
> diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
> index 56f7e06c673e..44b1d5c8dfed 100644
> --- a/drivers/hv/channel.c
> +++ b/drivers/hv/channel.c
> @@ -336,7 +336,7 @@ static int create_gpadl_header(enum hv_gpadl_type type, void *kbuffer,
> sizeof(struct gpa_range) + pfncount * sizeof(u64);
> msgheader = kzalloc(msgsize, GFP_KERNEL);
> if (!msgheader)
> - goto nomem;
> + return -ENOMEM;
>
> INIT_LIST_HEAD(&msgheader->submsglist);
> msgheader->msgsize = msgsize;
> @@ -386,8 +386,8 @@ static int create_gpadl_header(enum hv_gpadl_type type, void *kbuffer,
> list_del(&pos->msglistentry);
> kfree(pos);
> }
> -
> - goto nomem;
> + kfree(msgheader);
> + return -ENOMEM;
> }
>
> msgbody->msgsize = msgsize;
> @@ -416,8 +416,8 @@ static int create_gpadl_header(enum hv_gpadl_type type, void *kbuffer,
> sizeof(struct vmbus_channel_gpadl_header) +
> sizeof(struct gpa_range) + pagecount * sizeof(u64);
> msgheader = kzalloc(msgsize, GFP_KERNEL);
> - if (msgheader == NULL)
> - goto nomem;
> + if (!msgheader)
> + return -ENOMEM;
>
> INIT_LIST_HEAD(&msgheader->submsglist);
> msgheader->msgsize = msgsize;
> @@ -437,10 +437,6 @@ static int create_gpadl_header(enum hv_gpadl_type type, void *kbuffer,
> }
>
> return 0;
> -nomem:
> - kfree(msgheader);
> - kfree(msgbody);
> - return -ENOMEM;
> }
>
> /*
>
Should up to two memory areas still be released after a data processing failure?
Regards,
Markus
next prev parent reply other threads:[~2024-01-10 17:08 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-26 19:09 [PATCH] Drivers: hv: vmbus: One function call less in create_gpadl_header() after error detection Markus Elfring
2024-01-10 5:41 ` Michael Kelley
2024-01-10 10:58 ` Markus Elfring
2024-01-10 16:15 ` Michael Kelley
2024-01-10 17:08 ` Markus Elfring [this message]
2024-01-10 17:53 ` Michael Kelley
2024-01-10 18:37 ` Dan Carpenter
2024-01-10 22:17 ` Michael Kelley
2024-01-11 7:04 ` Dan Carpenter
2024-01-11 14:35 ` Michael Kelley
2024-01-10 11:29 ` [PATCH] " Dan Carpenter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1910913d-c3fe-45ab-a871-deda5318e2cf@web.de \
--to=markus.elfring@web.de \
--cc=cocci@inria.fr \
--cc=decui@microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=kys@microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhklinux@outlook.com \
--cc=wei.liu@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox