From: Dan Carpenter <dan.carpenter@oracle.com>
To: Vitaly Kuznetsov <vkuznets@redhat.com>
Cc: "K. Y. Srinivasan" <kys@microsoft.com>,
devel@linuxdriverproject.org, "Jason Wang" <jasowang@redhat.com>,
"Haiyang Zhang" <haiyangz@microsoft.com>,
linux-kernel@vger.kernel.org, "Radim Krčmář" <rkrcmar@redhat.com>
Subject: Re: [PATCH v2 1/3] Drivers: hv: check vmbus_device_create() return value in vmbus_process_offer()
Date: Mon, 19 Jan 2015 20:58:58 +0300 [thread overview]
Message-ID: <20150119175857.GE6456@mwanda> (raw)
In-Reply-To: <1421686573-12771-2-git-send-email-vkuznets@redhat.com>
On Mon, Jan 19, 2015 at 05:56:11PM +0100, Vitaly Kuznetsov wrote:
> vmbus_device_create() result is not being checked in vmbus_process_offer() and
> it can fail if kzalloc() fails. Add the check and do minor cleanup to avoid
> additional duplication of "free_channel(); return;" block.
>
> Reported-by: Jason Wang <jasowang@redhat.com>
> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
"out" is always a bad name for a label. It's too vague. It implies
that the code uses "One Err" style error handling which is bug prone and
I've ranted about that in the past so I won't here. This kind of coding
is buggier than direct returns. But recently I've been looking at bugs
where we return zero where the code should return a negative error code
and, wow, do I hate "out" labels!
if (function_whatever(xxx))
goto out;
[ thousands of lines removed. ]
out:
return ret;
Oh crap... Did the coder mean to return success or not???
If you use a direct return then the code looks like:
if (function_whatever(xxx))
return 0;
In that case, you can immediately see that the coder typed "0"
deliberately. Direct returns are best. I guess that's not directly
related to this code. But I didn't know that until I read to the bottom
of the patch and I already had this rant prepared in my head ready to
go...
"error" is a crap label name because it doesn't tell you what the code
does. A better name is "err_free_chan" or something which talks about
freeing the channel.
regards,
dan carpenter
next prev parent reply other threads:[~2015-01-19 17:59 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-19 16:56 [PATCH v2 0/3] Drivers: hv: vmbus: protect Offer/Rescind offer processing Vitaly Kuznetsov
2015-01-19 16:56 ` [PATCH v2 1/3] Drivers: hv: check vmbus_device_create() return value in vmbus_process_offer() Vitaly Kuznetsov
2015-01-19 17:58 ` Dan Carpenter [this message]
2015-01-19 18:03 ` Dan Carpenter
2015-01-20 9:43 ` Vitaly Kuznetsov
2015-01-20 10:51 ` Dan Carpenter
2015-01-19 16:56 ` [PATCH v2 2/3] Drivers: hv: rename sc_lock to the more generic lock Vitaly Kuznetsov
2015-01-19 16:56 ` [PATCH v2 3/3] Drivers: hv: vmbus: serialize Offer and Rescind offer Vitaly Kuznetsov
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=20150119175857.GE6456@mwanda \
--to=dan.carpenter@oracle.com \
--cc=devel@linuxdriverproject.org \
--cc=haiyangz@microsoft.com \
--cc=jasowang@redhat.com \
--cc=kys@microsoft.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rkrcmar@redhat.com \
--cc=vkuznets@redhat.com \
/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