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]
Date:	Thu, 15 Dec 2011 11:12:01 -0600
From:	Timur Tabi <timur@...escale.com>
To:	Andy Fleming <afleming@...escale.com>
CC:	<davem@...emloft.net>, <netdev@...r.kernel.org>,
	<linuxppc-dev@...abs.org>
Subject: Re: [PATCH] phylib: update mdiobus_alloc() to allocate extra private
 space

Andy Fleming wrote:
> Why? Doesn't this just obfuscate things a little, while providing no immediate benefit?

I see code like this frequently:

	bus = mdiobus_alloc();
	if (bus == NULL)
		return -ENOMEM;
	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
	if (priv == NULL) {
		err = -ENOMEM;
		goto out_free;
	}
	bus->priv = priv;

This can be replaced with:

	bus = mdiobus_alloc(sizeof(*priv));
	if (bus == NULL)
		return -ENOMEM;

So the benefit is in simplifying memory management.  Now you have only one allocation to manage, instead of two.

fbdev does the same thing, which is where I got the idea from.  See framebuffer_alloc().

-- 
Timur Tabi
Linux kernel developer at Freescale

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ