mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Zhouyi Zhou <zhouzhouyi@gmail.com>
To: <tglx@linutronix.de>, <mingo@redhat.com>, <hpa@zytor.com>,
	<x86@kernel.org>, <peterz@infradead.org>, <cpw@sgi.com>,
	<linux-kernel@vger.kernel.org>
Cc: Zhouyi Zhou <zhouzhouyi@gmail.com>, Zhouyi Zhou <yizhouzhou@ict.ac.cn>
Subject: [PATCH] x86/tlb_uv: Fixing some memory allocation failure in x86 UV
Date: Tue, 10 Jun 2014 15:35:23 +0800	[thread overview]
Message-ID: <1402385723-23138-1-git-send-email-zhouzhouyi@gmail.com> (raw)

Fixing some memory allocation failure handling in x86 UV

Signed-off-by: Zhouyi Zhou <yizhouzhou@ict.ac.cn>
---
 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;
 }
@@ -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);
+	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;
-- 
1.7.10.4


             reply	other threads:[~2014-06-10  7:35 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-10  7:35 Zhouyi Zhou [this message]
2014-06-10 23:02 ` H. Peter Anvin
2014-06-10 23:28   ` Thomas Gleixner
2014-06-11  1:46     ` Zhouyi Zhou
2014-06-11  2:50       ` Joe Perches
2014-06-10 23:27 ` David Rientjes

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1402385723-23138-1-git-send-email-zhouzhouyi@gmail.com \
    --to=zhouzhouyi@gmail.com \
    --cc=cpw@sgi.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=yizhouzhou@ict.ac.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®