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:	Fri, 20 May 2011 15:19:27 +0200
From:	Ingo Molnar <mingo@...e.hu>
To:	Cliff Wickman <cpw@....com>
Cc:	linux-kernel@...r.kernel.org, Thomas Gleixner <tglx@...utronix.de>,
	"H. Peter Anvin" <hpa@...or.com>
Subject: Re: [PATCH v2] x86: UV uv_tlb.c cleanup


Ok, the whole file looks a lot better now. A few small details:

* Cliff Wickman <cpw@....com> wrote:

> +	vp = kmalloc(nuvhubs * sizeof(struct uvhub_desc), GFP_KERNEL);
> +	uvhub_descs = (struct uvhub_desc *)vp;
> +	memset(uvhub_descs, 0, nuvhubs * sizeof(struct uvhub_desc));
> +	uvhub_mask = kzalloc((nuvhubs+7)/8, GFP_KERNEL);
> +
> +	if (get_cpu_topology(base_part_pnode, uvhub_descs, uvhub_mask)) {
> +		kfree(uvhub_descs);
> +		kfree(uvhub_mask);
> +		return 1;
> +	}
> +	if (summarize_uvhub_sockets(nuvhubs, uvhub_descs, uvhub_mask)) {
> +		kfree(uvhub_descs);
> +		kfree(uvhub_mask);
> +		return 1;
> +	}
> +
>  	kfree(uvhub_descs);
>  	kfree(uvhub_mask);
> +	init_per_cpu_tunables();
>  	return 0;

Look how the teardown of uvhub_descs and uvhub_mask is repeated 3 times (!).

What we do in the kernel instead are:

	if (func())
		goto fail;

	if (func2())
		goto fail;

	ret = 0;
out:
	kfree(ptr1);
	kfree(ptr2);

	return ret;

fail:
	ret = 1;
	goto out;
}

this makes it more obvious and more readable.

Thanks,

	Ingo
--
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