From patchwork Sun Aug 23 13:11:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 509852 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 64AE71402A0 for ; Sun, 23 Aug 2015 23:12:26 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=JWwmJG6i; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932136AbbHWNLw (ORCPT ); Sun, 23 Aug 2015 09:11:52 -0400 Received: from mail-pa0-f44.google.com ([209.85.220.44]:33664 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932135AbbHWNLt (ORCPT ); Sun, 23 Aug 2015 09:11:49 -0400 Received: by pacti10 with SMTP id ti10so3313309pac.0; Sun, 23 Aug 2015 06:11:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=wzYhZ3oiV0q/j6qm5fhWua7ry87pvtXUiGOYXJ9CpN4=; b=JWwmJG6igbW1Aqa79jJdBsC8i2veuo7Wj3uk+QvseOiBO22nqwQp9lgHXfOsA9RwvA 9YP/HHVTVNwKQO4OPRBwRd0MKj/C2yuPO8qUpiOhgTgjGbQ5d+B87eqsV+1zb1i1IQwq X68cIfwL2G6ZqYFb+2RHaqKlJkZDxNk3zy+/hFesC9gkfC9uJWLBOm5i73/5DtgvlHfJ D/uCPk2pv74UqUepMj5s7uI3coe91qYZrcE4Ec2j2eDT93cPSwSn1USLY50r6z08BUNe O03KeTy/xQjXHWqV3r9zrQWJopSwXBpC8CdPkYB750rnzIpGDTD01tdDbnNIJeftvQOQ igPQ== X-Received: by 10.66.221.193 with SMTP id qg1mr25892010pac.103.1440335508757; Sun, 23 Aug 2015 06:11:48 -0700 (PDT) Received: from linux-4gyl.site ([110.34.224.155]) by smtp.gmail.com with ESMTPSA id w6sm13988824pdn.46.2015.08.23.06.11.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 23 Aug 2015 06:11:47 -0700 (PDT) From: Peng Fan To: linus.walleij@linaro.org, gnurou@gmail.com, shawn.guo@linaro.org Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, van.freenix@gmail.com Subject: [PATCH 1/2] gpio: mxc: need to check return value of irq_alloc_generic_chip Date: Sun, 23 Aug 2015 21:11:52 +0800 Message-Id: <1440335513-14703-1-git-send-email-van.freenix@gmail.com> X-Mailer: git-send-email 1.8.4 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Need to check return value of irq_alloc_generic_chip, because it may return NULL. 1. Change mxc_gpio_init_gc return type from void to int. 2. Add a new lable out_irqdomain_remove to remove the irq domain when mxc_gpio_init_gc fail. Signed-off-by: Peng Fan Cc: Linus Walleij Cc: Alexandre Courbot --- drivers/gpio/gpio-mxc.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpio-mxc.c b/drivers/gpio/gpio-mxc.c index 9f7446a..45bbe729 100644 --- a/drivers/gpio/gpio-mxc.c +++ b/drivers/gpio/gpio-mxc.c @@ -339,13 +339,16 @@ static int gpio_set_wake_irq(struct irq_data *d, u32 enable) return 0; } -static void __init mxc_gpio_init_gc(struct mxc_gpio_port *port, int irq_base) +static int __init mxc_gpio_init_gc(struct mxc_gpio_port *port, int irq_base) { struct irq_chip_generic *gc; struct irq_chip_type *ct; gc = irq_alloc_generic_chip("gpio-mxc", 1, irq_base, port->base, handle_level_irq); + if (!gc) + return -ENOMEM; + gc->private = port; ct = gc->chip_types; @@ -359,6 +362,8 @@ static void __init mxc_gpio_init_gc(struct mxc_gpio_port *port, int irq_base) irq_setup_generic_chip(gc, IRQ_MSK(32), IRQ_GC_INIT_NESTED_LOCK, IRQ_NOREQUEST, 0); + + return 0; } static void mxc_gpio_get_hw(struct platform_device *pdev) @@ -476,12 +481,16 @@ static int mxc_gpio_probe(struct platform_device *pdev) } /* gpio-mxc can be a generic irq chip */ - mxc_gpio_init_gc(port, irq_base); + err = mxc_gpio_init_gc(port, irq_base); + if (err < 0) + goto out_irqdomain_remove; list_add_tail(&port->node, &mxc_gpio_ports); return 0; +out_irqdomain_remove: + irq_domain_remove(port->domain); out_irqdesc_free: irq_free_descs(irq_base, 32); out_gpiochip_remove: