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:	Mon, 8 Oct 2012 14:38:50 -0700
From:	Arnaldo Carvalho de Melo <acme@...stprotocols.net>
To:	David Ahern <dsahern@...il.com>
Cc:	linux-kernel@...r.kernel.org, mingo@...nel.org,
	peterz@...radead.org, fweisbec@...il.com,
	Xiao Guangrong <xiaoguangrong@...ux.vnet.ibm.com>,
	Dong Hao <haodong@...ux.vnet.ibm.com>
Subject: Re: [PATCH 07/12] perf kvm: handle realloc failures

Em Mon, Oct 08, 2012 at 02:34:55PM -0600, David Ahern escreveu:
> On 10/8/12 2:19 PM, Arnaldo Carvalho de Melo wrote:
> >>+	prev = event->vcpu;
> >>  	event->vcpu = realloc(event->vcpu,
> >>  			      event->max_vcpu * sizeof(*event->vcpu));
> >>  	if (!event->vcpu) {
> >>+		free(prev);
> >>  		pr_err("Not enough memory\n");

> >Unfamiliar way of doing it, usually we do it like:

> >   	vcpu = realloc(event->vcpu, event->max_vcpu * sizeof(*event->vcpu));

> >	if (!vcpu) {
> >   		pr_err("Not enough memory\n");
> >		return -1;
> >	}

> >	event->vcpu = vcpu;

> >I.e. we don't trow away the old value of event->vcpu.
> 
> right. Command is going to exit on a failure, so leaving the old
> value does not have any impact. I can leave the old if you want it
> for consistency.

I think do it in the familiar way for consistency.

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