From: Dan Carpenter <dan.carpenter@oracle.com>
To: "K. Y. Srinivasan" <kys@microsoft.com>
Cc: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org,
devel@linuxdriverproject.org, olaf@aepfle.de, apw@canonical.com,
jasowang@redhat.com, sitsofe@gmail.com, stable@vger.kernel.org
Subject: Re: [PATCH 3/4] Drivers: hv: vmbus: Cleanup vmbus_close_internal()
Date: Wed, 27 Aug 2014 13:04:30 +0300 [thread overview]
Message-ID: <20140827100430.GF5046@mwanda> (raw)
In-Reply-To: <1409079952-16599-3-git-send-email-kys@microsoft.com>
On Tue, Aug 26, 2014 at 12:05:51PM -0700, K. Y. Srinivasan wrote:
> -static void vmbus_close_internal(struct vmbus_channel *channel)
> +static int vmbus_close_internal(struct vmbus_channel *channel)
> {
> struct vmbus_channel_close_channel *msg;
> - int ret;
> + int ret = 0;
GCC has a feature which warns about uninitialized variables. Those
features are there to help prevent bugs. You are turning the feature
off here by initializing it with a bogus value. Don't do that.
>
> channel->state = CHANNEL_OPEN_STATE;
> channel->sc_creation_callback = NULL;
> @@ -502,11 +502,28 @@ static void vmbus_close_internal(struct vmbus_channel *channel)
>
> ret = vmbus_post_msg(msg, sizeof(struct vmbus_channel_close_channel));
>
> - BUG_ON(ret != 0);
> + if (ret) {
> + pr_err("Close failed: close post msg return is %d\n", ret);
> + /*
> + * If we failed to post the close msg,
> + * it is perhaps better to leak memory.
> + */
> + goto close_err;
Just return directly. Don't introduce do-nothing gotos to lead the
reader through a series of pointless goto hops.
The goto label is poorly chosen. Label names should be based on the
thing which they do. "close_err" implies that something is closed but
that's not the case, the label doesn't do anything.
regards,
dan carpenter
next prev parent reply other threads:[~2014-08-27 10:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1409079922-16560-1-git-send-email-kys@microsoft.com>
2014-08-26 19:05 ` [PATCH 1/4] Drivers: hv: vmbus: Cleanup vmbus_post_msg() K. Y. Srinivasan
2014-08-26 19:05 ` [PATCH 2/4] Drivers: hv: vmbus: Cleanup vmbus_teardown_gpadl() K. Y. Srinivasan
2014-08-26 19:05 ` [PATCH 3/4] Drivers: hv: vmbus: Cleanup vmbus_close_internal() K. Y. Srinivasan
2014-08-27 10:04 ` Dan Carpenter [this message]
2014-08-26 19:05 ` [PATCH 4/4] Drivers: hv: vmbus: Cleanup vmbus_establish_gpadl() K. Y. Srinivasan
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=20140827100430.GF5046@mwanda \
--to=dan.carpenter@oracle.com \
--cc=apw@canonical.com \
--cc=devel@linuxdriverproject.org \
--cc=gregkh@linuxfoundation.org \
--cc=jasowang@redhat.com \
--cc=kys@microsoft.com \
--cc=linux-kernel@vger.kernel.org \
--cc=olaf@aepfle.de \
--cc=sitsofe@gmail.com \
--cc=stable@vger.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;
as well as URLs for NNTP newsgroup(s).