From patchwork Wed Mar 10 09:31:01 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Damm X-Patchwork-Id: 84513 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o2A9V74G013568 for ; Wed, 10 Mar 2010 09:31:07 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754465Ab0CJJbG (ORCPT ); Wed, 10 Mar 2010 04:31:06 -0500 Received: from mail-gw0-f46.google.com ([74.125.83.46]:48215 "EHLO mail-gw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750881Ab0CJJbF (ORCPT ); Wed, 10 Mar 2010 04:31:05 -0500 Received: by gwb15 with SMTP id 15so4069672gwb.19 for ; Wed, 10 Mar 2010 01:31:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:date:message-id :subject; bh=/YDqxkkfv7asM+7QgOW8w5gtSpeX7NiOVhoow4zueek=; b=mLplyO5Hd2U9rKZ3wFRbHY+wK/VghSLwlROrxzOyqi+/XX4LTCl4EmSu69Ez8VjRgS x5mubc8Msvf4Gn1W70GqG29D1mBYn9Evfrxa0QXihzvg79hcKVpgG7xJsu9uQ7xXOyxK Ty9dNpqQub5/U4+FAP/ZrnmEpNoNXZqNJFgmo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:date:message-id:subject; b=VVf/wockEEq4DKEVVcRybj1ca1Fy92TNUFDqYCW7Fylzm1Qq4qNpmmgY6I5evOGkpo K4KdsPj5lTejU18NLIl7+0fMy72WGq0usRGEvVlGujx96OSxfO6aMUXoJvgmFVF03YnJ FCkmsGZQcnFENqpzHBPtsX5fRrgQ9jEiwVwEU= Received: by 10.90.10.38 with SMTP id 38mr1331996agj.74.1268213461426; Wed, 10 Mar 2010 01:31:01 -0800 (PST) Received: from [127.0.0.1] (49.14.32.202.bf.2iij.net [202.32.14.49]) by mx.google.com with ESMTPS id 13sm5090732gxk.4.2010.03.10.01.30.58 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 10 Mar 2010 01:30:59 -0800 (PST) From: Magnus Damm To: lethal@linux-sh.org Cc: Magnus Damm , linux-sh@vger.kernel.org Date: Wed, 10 Mar 2010 18:31:01 +0900 Message-Id: <20100310093101.5422.38371.sendpatchset@t400s> Subject: [PATCH] sh: add INTC out of memory error handling Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Wed, 10 Mar 2010 09:31:07 +0000 (UTC) --- 0005/drivers/sh/intc.c +++ work/drivers/sh/intc.c 2010-03-10 16:31:22.000000000 +0900 @@ -789,13 +789,15 @@ static void intc_redirect_irq(unsigned i generic_handle_irq((unsigned int)get_irq_data(irq)); } -void __init register_intc_controller(struct intc_desc *desc) +int __init register_intc_controller(struct intc_desc *desc) { unsigned int i, k, smp; struct intc_hw_desc *hw = &desc->hw; struct intc_desc_int *d; d = kzalloc(sizeof(*d), GFP_NOWAIT); + if (!d) + goto err0; INIT_LIST_HEAD(&d->list); list_add(&d->list, &intc_list); @@ -806,8 +808,13 @@ void __init register_intc_controller(str d->nr_reg += hw->ack_regs ? hw->nr_ack_regs : 0; d->reg = kzalloc(d->nr_reg * sizeof(*d->reg), GFP_NOWAIT); + if (!d->reg) + goto err1; + #ifdef CONFIG_SMP d->smp = kzalloc(d->nr_reg * sizeof(*d->smp), GFP_NOWAIT); + if (!d->smp) + goto err2; #endif k = 0; @@ -822,6 +829,8 @@ void __init register_intc_controller(str if (hw->prio_regs) { d->prio = kzalloc(hw->nr_vectors * sizeof(*d->prio), GFP_NOWAIT); + if (!d->prio) + goto err3; for (i = 0; i < hw->nr_prio_regs; i++) { smp = IS_SMP(hw->prio_regs[i]); @@ -833,6 +842,8 @@ void __init register_intc_controller(str if (hw->sense_regs) { d->sense = kzalloc(hw->nr_vectors * sizeof(*d->sense), GFP_NOWAIT); + if (!d->sense) + goto err4; for (i = 0; i < hw->nr_sense_regs; i++) k += save_reg(d, k, hw->sense_regs[i].reg, 0); @@ -912,6 +923,22 @@ void __init register_intc_controller(str /* enable bits matching force_enable after registering irqs */ if (desc->force_enable) intc_enable_disable_enum(desc, d, desc->force_enable, 1); + + return 0; + err4: + kfree(d->prio); + err3: +#ifdef CONFIG_SMP + kfree(d->smp); + err2: +#endif + kfree(d->reg); + err1: + kfree(d); + err0: + pr_err("unable to allocate INTC memory\n"); + + return -ENOMEM; } static int intc_suspend(struct sys_device *dev, pm_message_t state) --- 0005/include/linux/sh_intc.h +++ work/include/linux/sh_intc.h 2010-03-10 16:18:59.000000000 +0900 @@ -92,7 +92,7 @@ struct intc_desc symbol __initdata = { prio_regs, sense_regs, ack_regs), \ } -void __init register_intc_controller(struct intc_desc *desc); +int __init register_intc_controller(struct intc_desc *desc); int intc_set_priority(unsigned int irq, unsigned int prio); int reserve_irq_vector(unsigned int irq);