Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3248680imm; Mon, 13 Aug 2018 08:24:02 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxWGNyka8jkY/+dH5tyGHdxJ1tU+Ip7fdLi+vY/0XfR/Z5wWqmje0oVmmSv8+F6N6arrSSF X-Received: by 2002:a17:902:bcc6:: with SMTP id o6-v6mr16979235pls.117.1534173842884; Mon, 13 Aug 2018 08:24:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534173842; cv=none; d=google.com; s=arc-20160816; b=MJQz6RSYjaQQIwBI7/N7Aw1NTmcvSzQvvweRCa+XnNHvUnD1txuif0S3hDXTWPa7UV aZRLThagXnB0QrOO8cge8JS7RHG50nzxsmgDNEHPl+AUdI/fseg3bjxUfeX4gkwsSHzx MnyzapRk67xoST56EKovvPs4luF1dWre36x6HWwf3lp1JaK6b4eKPtuTnekNkb/opvMh JmU+uUboJvpYsj/sdF3vJ4bo3ArxRRxokMAOPNYPbiRuARDZyVYQnM7gmmU5lPkqmkAw Qk5RtoHw4yTFhpKLp/prdQ+0pX4bBdVDs/caMSv1TK816w7hxqHYCywvrf+7J1xC3RlI 8Kag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject :arc-authentication-results; bh=6xW2D1sQKnsyEYSw+srGrm2VI/eF5sO/uUtfYDvsK7Q=; b=kT8+AiGPntBOh1z2ANxaaBqaKj8sKVjbYXAw3miOXYLY6eImA+gdQHBwNsVFDcv0+f yG0gfa3wAkzAM9vJTSOGt9t6t/MJEDywU9dV1z7QfjA8+G5ZRwc/c8IGsYQKSMvA9j41 1UW+mgti+edf7y9g1H894jJViHWMvzi6hE2wnhUO8y+SnGn+BMu3Axz6MHhCchgroFOq Qyr1PmJawJMZplgaM/nRuBkiWsoylBeMtvaKcyUwc7tyR4ElRhPaTlwPLsmUnlKYGIjx D9ayZTdg2D9yBGFqTA1C2hmzO7iv0Ki95xkK6PiAo9tyNmyK4TTsrZ8yBpB0Muy4J9qZ GRHQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d1-v6si12491302plr.455.2018.08.13.08.23.48; Mon, 13 Aug 2018 08:24:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730054AbeHMSFb (ORCPT + 99 others); Mon, 13 Aug 2018 14:05:31 -0400 Received: from foss.arm.com ([217.140.101.70]:33078 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728293AbeHMSFb (ORCPT ); Mon, 13 Aug 2018 14:05:31 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 800B180D; Mon, 13 Aug 2018 08:22:49 -0700 (PDT) Received: from [10.4.13.119] (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 951923F73C; Mon, 13 Aug 2018 08:22:47 -0700 (PDT) Subject: Re: [PATCH] irqchip/stm32: fix init error handling To: Dan Carpenter , Thomas Gleixner , Ludovic Barre Cc: Jason Cooper , Maxime Coquelin , Alexandre Torgue , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel-janitors@vger.kernel.org References: <20180808120319.akmstg3ads325xcy@kili.mountain> From: Marc Zyngier Organization: ARM Ltd Message-ID: <99d66ae8-f497-0108-8168-6e46fdf2fe1d@arm.com> Date: Mon, 13 Aug 2018 16:22:44 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180808120319.akmstg3ads325xcy@kili.mountain> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/08/18 13:03, Dan Carpenter wrote: > If there are any errors in stm32_exti_host_init() then it leads to a > NULL dereference in the callers. The function should clean up after > itself. > > Fixes: f9fc1745501e ("irqchip/stm32: Add host and driver data structures") > Signed-off-by: Dan Carpenter > > diff --git a/drivers/irqchip/irq-stm32-exti.c b/drivers/irqchip/irq-stm32-exti.c > index 3df527fcf4e1..0a2088e12d96 100644 > --- a/drivers/irqchip/irq-stm32-exti.c > +++ b/drivers/irqchip/irq-stm32-exti.c > @@ -603,17 +603,24 @@ stm32_exti_host_data *stm32_exti_host_init(const struct stm32_exti_drv_data *dd, > sizeof(struct stm32_exti_chip_data), > GFP_KERNEL); > if (!host_data->chips_data) > - return NULL; > + goto free_host_data; > > host_data->base = of_iomap(node, 0); > if (!host_data->base) { > pr_err("%pOF: Unable to map registers\n", node); > - return NULL; > + goto free_chips_data; > } > > stm32_host_data = host_data; > > return host_data; > + > +free_chips_data: > + kfree(host_data->chips_data); > +free_host_data: > + kfree(host_data); > + > + return NULL; > } > > static struct > @@ -665,10 +672,8 @@ static int __init stm32_exti_init(const struct stm32_exti_drv_data *drv_data, > struct irq_domain *domain; > > host_data = stm32_exti_host_init(drv_data, node); > - if (!host_data) { > - ret = -ENOMEM; > - goto out_free_mem; > - } > + if (!host_data) > + return -ENOMEM; > > domain = irq_domain_add_linear(node, drv_data->bank_nr * IRQS_PER_BANK, > &irq_exti_domain_ops, NULL); > @@ -725,7 +730,6 @@ static int __init stm32_exti_init(const struct stm32_exti_drv_data *drv_data, > irq_domain_remove(domain); > out_unmap: > iounmap(host_data->base); > -out_free_mem: > kfree(host_data->chips_data); > kfree(host_data); > return ret; > @@ -752,10 +756,8 @@ __init stm32_exti_hierarchy_init(const struct stm32_exti_drv_data *drv_data, > } > > host_data = stm32_exti_host_init(drv_data, node); > - if (!host_data) { > - ret = -ENOMEM; > - goto out_free_mem; > - } > + if (!host_data) > + return -ENOMEM; > > for (i = 0; i < drv_data->bank_nr; i++) > stm32_exti_chip_init(host_data, i, node); > @@ -777,7 +779,6 @@ __init stm32_exti_hierarchy_init(const struct stm32_exti_drv_data *drv_data, > > out_unmap: > iounmap(host_data->base); > -out_free_mem: > kfree(host_data->chips_data); > kfree(host_data); > return ret; > Queued, thanks, M. -- Jazz is not dead. It just smells funny...