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] [day] [month] [year] [list]
Message-ID: <20130820211814.GM27005@ZenIV.linux.org.uk>
Date:	Tue, 20 Aug 2013 22:18:14 +0100
From:	Al Viro <viro@...IV.linux.org.uk>
To:	Alex Williamson <alex.williamson@...hat.com>
Cc:	linux-kernel@...r.kernel.org, kvm@...r.kernel.org
Subject: Re: [PATCH] vfio-pci: Use fdget() rather than eventfd_fget()

On Tue, Aug 20, 2013 at 01:18:07PM -0600, Alex Williamson wrote:
> eventfd_fget() tests to see whether the file is an eventfd file, which
> we then immediately pass to eventfd_ctx_fileget(), which again tests
> whether the file is an eventfd file.  Simplify slightly by using
> fdget() so that we only test that we're looking at an eventfd once.
> fget() could also be used, but fdget() makes use of fget_light() for
> another slight optimization.

Umm...

> @@ -210,8 +210,8 @@ fail:
>  	if (ctx && !IS_ERR(ctx))
>  		eventfd_ctx_put(ctx);
>  
> -	if (file && !IS_ERR(file))
> -		fput(file);
> +	if (irqfd.file)
> +		fdput(irqfd);
>  
>  	kfree(virqfd);

IMO it's a bad style; you have three failure exits leading here, and those
ifs are nothing but "how far did we get before we'd failed".

fail3:
	eventfd_ctx_put(ctx);
fail2:
	fdput(irqfd);
fail1:
  	kfree(virqfd);

is much easier to analyse.  It's a very common pattern and IME it's more
robust than this kind of "flexibility"...
--
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