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, 23 Jul 2015 10:29:31 +0300
From:	Dan Carpenter <dan.carpenter@...cle.com>
To:	Dmitry Kalinkin <dmitry.kalinkin@...il.com>
Cc:	linux-kernel@...r.kernel.org, devel@...verdev.osuosl.org,
	Manohar Vanga <manohar.vanga@...il.com>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Igor Alekseev <igor.alekseev@...p.ru>,
	Martyn Welch <martyn.welch@...com>,
	"Hans J. Koch" <hjk@...sjkoch.de>
Subject: Re: [RFC] Generic VME UIO

On Wed, Jul 22, 2015 at 09:09:06PM +0300, Dmitry Kalinkin wrote:
> +	for (level = 1; level <= 7; level++) {
> +		char *level_node_name = kasprintf(GFP_KERNEL, "%d", level);
> +		struct kobject *level_node = kobject_create_and_add(
> +			level_node_name, kobj);
> +		if (!level_node)
> +			return -ENOMEM;

>From the zero day testing results, what I've noticed is that allocations
in the initializer are more error prone.  You should be testing the
results from kasprintf() and there is a leak if the "level_node"
allocation fails.

		char *level_node_name;
		struct kobject *level_node;

		level_node_name = kasprintf(GFP_KERNEL, "%d", level);
		if (!level_node_name)
			return -ENOMEM;
		level_node = kobject_create_and_add(level_node_name, kobj);
		if (!level_node) {
			kfree(level_node_name);
			return -ENOMEM;
		}

The other advantage to writing it like this is that you don't run into
the 80 char limit.

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