Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753296AbaFJX1K (ORCPT ); Tue, 10 Jun 2014 19:27:10 -0400 Received: from mail-ig0-f173.google.com ([209.85.213.173]:38325 "EHLO mail-ig0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751758AbaFJX1I (ORCPT ); Tue, 10 Jun 2014 19:27:08 -0400 Date: Tue, 10 Jun 2014 16:27:03 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Zhouyi Zhou cc: tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, peterz@infradead.org, cpw@sgi.com, linux-kernel@vger.kernel.org, Zhouyi Zhou Subject: Re: [PATCH] x86/tlb_uv: Fixing some memory allocation failure in x86 UV In-Reply-To: <1402385723-23138-1-git-send-email-zhouzhouyi@gmail.com> Message-ID: References: <1402385723-23138-1-git-send-email-zhouzhouyi@gmail.com> User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 10 Jun 2014, Zhouyi Zhou wrote: > Fixing some memory allocation failure handling in x86 UV > > Signed-off-by: Zhouyi Zhou > --- > arch/x86/platform/uv/tlb_uv.c | 17 +++++++++++++++++ > 1 file changed, 18 insertions(+) > > diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c > index dfe605a..a434768 100644 > --- a/arch/x86/platform/uv/tlb_uv.c > +++ b/arch/x86/platform/uv/tlb_uv.c > @@ -1965,6 +1966,10 @@ static void make_per_cpu_thp(struct bau_control *smaster) > size_t hpsz = sizeof(struct hub_and_pnode) * num_possible_cpus(); > > smaster->thp = kmalloc_node(hpsz, GFP_KERNEL, smaster->osnode); > + if (!smaster->thp) { > + pr_err("ERROR: out of memory, can not create hub and pnode!\n"); > + return; > + } > memset(smaster->thp, 0, hpsz); > for_each_present_cpu(cpu) { > smaster->thp[cpu].pnode = uv_cpu_hub_info(cpu)->pnode; > @@ -1980,6 +1985,8 @@ static void make_per_hub_cpumask(struct bau_control *hmaster) > int sz = sizeof(cpumask_t); > > hmaster->cpumask = kzalloc_node(sz, GFP_KERNEL, hmaster->osnode); > + if (!hmaster->cpumask) > + pr_err("ERROR: out of memory, can not create cpumask!\n"); > } > > /* > @@ -2056,11 +2063,15 @@ static int __init summarize_uvhub_sockets(int nuvhubs, > if (scan_sock(sdp, bdp, &smaster, &hmaster)) > return 1; > make_per_cpu_thp(smaster); > + if (!smaster->thp) > + return 1; > } > socket++; > socket_mask = (socket_mask >> 1); > } > make_per_hub_cpumask(hmaster); > + if (!hmaster->cpumask) > + return 1; > } > return 0; > } You're missing that make_per_hub_cpumask() isn't marked __init or freed after bootstrap so the correct fix would be to fold its implementation into summarize_uvhub_sockets() and return non-zero when the kzalloc_node() fails. > @@ -2077,9 +2088,16 @@ static int __init init_per_cpu(int nuvhubs, int base_part_pnode) > timeout_us = calculate_destination_timeout(); > > vp = kmalloc(nuvhubs * sizeof(struct uvhub_desc), GFP_KERNEL); This should also be a kcalloc(). > + if (!vp) > + return 1; > + > uvhub_descs = (struct uvhub_desc *)vp; > memset(uvhub_descs, 0, nuvhubs * sizeof(struct uvhub_desc)); > uvhub_mask = kzalloc((nuvhubs+7)/8, GFP_KERNEL); > + if (!uvhub_mask) { > + kfree(uvhub_descs); > + return 1; > + } > > if (get_cpu_topology(base_part_pnode, uvhub_descs, uvhub_mask)) > goto fail; -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/