From patchwork Tue Jan 2 10:23:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 123110 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp8797284qgn; Tue, 2 Jan 2018 02:25:23 -0800 (PST) X-Google-Smtp-Source: ACJfBovbC7PoipsV4YTcMQJzc3LQVWlC4m+y6kRr2Nn+zKNzMcOldoUBZKQucgS7Q70lotIaEbDv X-Received: by 10.159.244.147 with SMTP id y19mr571317plr.404.1514888723544; Tue, 02 Jan 2018 02:25:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514888723; cv=none; d=google.com; s=arc-20160816; b=iGylOaqOuKaqGLGdK1qOlKWKxoOBJY4lAzlLkG4KBvM01frvdGfNQHzyYjFJmXAq3J l96ndPKorADmw9dY1MG84+gHzJyVW20gUbd7Zn+ezkzMYzwVslPp3z2PaFQeoEgU/g5f /PIYVjTPf2u/4Ts57lj1fdO5GUEaWIlV1KFmvpAbpSFiI28TC47Fr21DgzKKVtwbyd2K XGfM63nEhdA/ZPwQOu9XkarfjIsncUdLwweL8a6OFbWeqd/FzJ+QiM49B3folS3O1adN tnw5BzBSCB/mFJaadTeHRizvVT4nQ7vv1GTtxT4cF4AqDCltNGfZzZYhmSfOeHgVOYl0 81Tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=lJzRPItJ08CQ/g2ZmoJJfFjWV/zGes7J2FXNDvVwxfU=; b=NlfpcP9Hs2XS8GildT7iGEydOZ8B8r9zhZTVUj1v8FcFOOBdHf7Oae6Zzih2PWzDm+ /nsSCXOKGg7LJUtvWxdv+b7syznEiT5ZDnXcm9059Zs6ZFDEXZKmlGOvq7vwS+VWfN6Z buDnaETI8a5+iD6jPebl/4Q4dSHNEsVqmDmr2pYslKAoL4aYFbO6XIEbhapz86YRWgTL iOmFVP0uqNSjpxW7moCoH0QkZ4IDVEQaNctoaufC1SseeUgCC5PcV01o5XbbcdKdmrwP /v8mr2UiSDAXIcnoON7amIOm5xsBMh5pfV78VyoAccbxBcpC9oTzwoj0y1lbunCQxpKg vAlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Lyh4fXwr; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j12si4586945pgq.184.2018.01.02.02.25.23; Tue, 02 Jan 2018 02:25:23 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Lyh4fXwr; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751938AbeABKZW (ORCPT + 6 others); Tue, 2 Jan 2018 05:25:22 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:33972 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751546AbeABKZV (ORCPT ); Tue, 2 Jan 2018 05:25:21 -0500 Received: by mail-lf0-f68.google.com with SMTP id h140so4408970lfg.1 for ; Tue, 02 Jan 2018 02:25:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=LCGBbvqi2g05OQBsKYZaehrmGeo1aI6zgm0RP1F4UtM=; b=Lyh4fXwr6n2UZxUE3wJz0O9T4vViAaOFm3ZA6zNGT78rq4RIIxlDoK/GERqzziTYKL WxPFqDKmx52/e1XBmWsBbCAszmLQ41UYXSLuORwoleXZJJvSuoBhNrxbqEpnMaVi9RSd 7XFMaXWGs9xTEUAgyrwgMVvb3CJ9eyLrbLuLo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=LCGBbvqi2g05OQBsKYZaehrmGeo1aI6zgm0RP1F4UtM=; b=hD7vm8HYY9s/Q64h5BQpaX0ja/TjjsPIPYaZKFlaLqq5EPolFvWT+g7AaN5wo2VIMF I9BkTcNReC2oRHtpEkltBoVsFPA0GmwExPQ6OjCdUALfooM9EycUo9YcvRp6UkiBBDr3 C5CA9Q9oV2VxVqz0k7V2fUJbFzgw21zeESOwxgUGcjRC1SAyEA8Eew3M1Xxjuxtpr1ts wrEhT6qhLM4/MOAgwfsKaQwnP9hTY3R+f58RXLWR7FipZt2SXRrt3CiQe3mFGvJ69J5q Cc8gIi0Vxidwlo5tcRmOHy4wjiBH9c+lqv/Br3J7dogcpM3vIdkVF/9yvlyWti7cUTJq FSmg== X-Gm-Message-State: AKGB3mLchdvkWS+2AnNSAhrDK2tPfIrhCdT1l/pbnnS5Mq35FpdctGTb IcBN7AlEals3XlU7jJ1EXxX+Wv6bs4w= X-Received: by 10.46.91.79 with SMTP id p76mr27893326ljb.22.1514888719760; Tue, 02 Jan 2018 02:25:19 -0800 (PST) Received: from localhost.localdomain (c-cb7471d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.116.203]) by smtp.gmail.com with ESMTPSA id s195sm3454600lfs.77.2018.01.02.02.25.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jan 2018 02:25:19 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org Cc: Linus Walleij , Johan Hovold Subject: [PATCH] gpio: omap: Fix error path on chip init Date: Tue, 2 Jan 2018 11:23:14 +0100 Message-Id: <20180102102314.12906-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org The error path was leaking a gpio_chip at one point. Cc: Johan Hovold Signed-off-by: Linus Walleij --- drivers/gpio/gpio-omap.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) -- 2.14.3 -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Reviewed-by: Johan Hovold diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c index e136d666f1e5..d83e8624964a 100644 --- a/drivers/gpio/gpio-omap.c +++ b/drivers/gpio/gpio-omap.c @@ -1104,7 +1104,8 @@ static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc) -1, 0, bank->width, 0); if (irq_base < 0) { dev_err(bank->chip.parent, "Couldn't allocate IRQ numbers\n"); - return -ENODEV; + ret = -ENODEV; + goto err_remove_chip; } #endif @@ -1122,8 +1123,8 @@ static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc) if (ret) { dev_err(bank->chip.parent, "Couldn't add irqchip to gpiochip %d\n", ret); - gpiochip_remove(&bank->chip); - return -ENODEV; + ret = -ENODEV; + goto err_remove_chip; } gpiochip_set_chained_irqchip(&bank->chip, irqc, bank->irq, NULL); @@ -1132,8 +1133,12 @@ static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc) omap_gpio_irq_handler, 0, dev_name(bank->chip.parent), bank); if (ret) - gpiochip_remove(&bank->chip); + goto err_remove_chip; + return 0; + +err_remove_chip: + gpiochip_remove(&bank->chip); return ret; }