Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp730893imm; Thu, 13 Sep 2018 06:58:30 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYRr6+sXASsZTciOMb/Dnojg0DO+kIae+8DPUFj33A19H3rNrcrclU0cYdv7YvsUgtWg+2d X-Received: by 2002:a17:902:9045:: with SMTP id w5-v6mr7553443plz.10.1536847110212; Thu, 13 Sep 2018 06:58:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536847110; cv=none; d=google.com; s=arc-20160816; b=y2Ua9vS1QE6mmGrjtEC5P923kOqOPzHL4lDVnQQuGlU6yTGjHBaMIce3GztMLIYlsO zDfnzPB7cwv/NsxeX2+amTo4WU25GTlX6sTPg4LiXhxojAB8DT9H+7sdGwfcFjxz472J In6gNYd3et7hE3VeIJWSbun/29GV0WxpGb9FvnxB8DidkrBCfcPxBbfpSKiuH5Lez2WG E191fyIoAuC0Sloh9h+rkwv7nLXYo2QDNxyplNKd/NPJdqFtEpmx79TZmjbNbxBXtPwB Qe2JRNi8xYE52JJzYnNkeYh8Afang59p4CUpFWPo7EIpgVZQpqDSgof/QB8prOz1VUeM bjFg== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=x7ah9IDL6rt60XSniRn6zo7tmysCjkFw/9p/3Pz/ZHE=; b=BiXeDWuz/rbXNTRgeMruADW3ilrj6/hV4Ulr83xICe0y+iKcS7saM+9kDe05LoU5+V FFqH96EyRANQLZxxh05M150BNDoEYFfcGQ5BmNGDskMfRz1UzUloUw7EbvKutCK4OhSQ CanZ2hy7NmalL9wgT0XnTJZ+hpnAz9/KaG2fzLvJNPK6Undnouf9W5QlTW0J5hHTr+Bh FV6MOo25wR9HISxuS6JF48g1Yf5M/YlGkbTiQsVIj+DokfMVO8QN5u2LirbgmaSxdTo2 ubDRncYwpX9rsuduT7tV3ItwZlmJxp/hWv3mRIuSj44Fe5KMromhsdfsoH+7BLx2O23M YxSw== 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 m7-v6si4051721pfm.288.2018.09.13.06.58.15; Thu, 13 Sep 2018 06:58:30 -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 S1731427AbeIMTGY (ORCPT + 99 others); Thu, 13 Sep 2018 15:06:24 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:34214 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730337AbeIMTGX (ORCPT ); Thu, 13 Sep 2018 15:06:23 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id C8470D10; Thu, 13 Sep 2018 13:56:46 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ludovic Barre , Dan Carpenter , Marc Zyngier , Sasha Levin Subject: [PATCH 4.18 091/197] irqchip/stm32: Fix init error handling Date: Thu, 13 Sep 2018 15:30:40 +0200 Message-Id: <20180913131845.174348825@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180913131841.568116777@linuxfoundation.org> References: <20180913131841.568116777@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dan Carpenter [ Upstream commit 4096165d55218a6f58b6c2ebc5d2428aa0aa70e4 ] 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") Reviewed-by: Ludovic Barre Signed-off-by: Dan Carpenter Signed-off-by: Marc Zyngier Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/irqchip/irq-stm32-exti.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) --- a/drivers/irqchip/irq-stm32-exti.c +++ b/drivers/irqchip/irq-stm32-exti.c @@ -602,17 +602,24 @@ stm32_exti_host_data *stm32_exti_host_in 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 @@ -664,10 +671,8 @@ static int __init stm32_exti_init(const 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); @@ -724,7 +729,6 @@ out_free_domain: irq_domain_remove(domain); out_unmap: iounmap(host_data->base); -out_free_mem: kfree(host_data->chips_data); kfree(host_data); return ret; @@ -751,10 +755,8 @@ __init stm32_exti_hierarchy_init(const s } 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); @@ -776,7 +778,6 @@ __init stm32_exti_hierarchy_init(const s out_unmap: iounmap(host_data->base); -out_free_mem: kfree(host_data->chips_data); kfree(host_data); return ret;