lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150119175857.GE6456@mwanda>
Date:	Mon, 19 Jan 2015 20:58:58 +0300
From:	Dan Carpenter <dan.carpenter@...cle.com>
To:	Vitaly Kuznetsov <vkuznets@...hat.com>
Cc:	"K. Y. Srinivasan" <kys@...rosoft.com>,
	devel@...uxdriverproject.org, Jason Wang <jasowang@...hat.com>,
	Haiyang Zhang <haiyangz@...rosoft.com>,
	linux-kernel@...r.kernel.org,
	Radim Krčmář <rkrcmar@...hat.com>
Subject: Re: [PATCH v2 1/3] Drivers: hv: check vmbus_device_create() return
 value in vmbus_process_offer()

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@...hat.com>
> Signed-off-by: Vitaly Kuznetsov <vkuznets@...hat.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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ