Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3349099pxu; Sat, 19 Dec 2020 23:18:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJzzvorBxh2MZpIGlUVyRAOCfRRROwY+bA3fpP7EegF5bAtbvkg6LJNicdnE4esivCyWOyme X-Received: by 2002:a05:6402:407:: with SMTP id q7mr11383329edv.312.1608448707903; Sat, 19 Dec 2020 23:18:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608448707; cv=none; d=google.com; s=arc-20160816; b=gXF4dLin6BlqDOB1JK7/29c7h0+NKONQHRU6h12QCXzSR+w0Hawyr6Z4HI5gjesPWr hDo9rSby7NLAz84rOp2PB/ArStPMfhXHNkiycxaXNQV+ZGGrlUmLtxv6VSudfKnlKLro Jfqw8azsa9L0uqRQWql/SlgFPqe6AxKuPAAzFU4KVxmPPy9ATmsjAzo9n4W4bJa+Lq+g cWzcGHTQFsAvVNF6coIuIMzYrq8tE8zuV747HuZpTDIroPV+1EntuSIxai/OjXmo19so KPg+xDC7GoeVasmfl9iVwEI9hmVk+j9OGz7HnXu/mD5BX/cfMj+wiI/XjY/jVnRuPyXQ OrqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=1M9BFwKZ41oS5ENcGjuTLNvJjyeqMEozlctkvK6z/24=; b=VpNgg8oAkfcI3ErUvyp194hY6bSr90i5Y9sOQeYvmiufRYcpe2OU5+SsPbD4P8TWQF cBVP/ajInUcda2fvEo/R71jV1/WRuNUNbvieHk+l69aEXlmJC98svFq99avOZZa/TNyW pFjzTcTbsy5a/gLeKLOlo4PZ7gYsqN+djX6uCct8MCLsLNQlW/mNOxIMA3FKMaSrzqdu JRMu9ujoalbWArODT+x+HU3Q8sFwUwLRCVtNwiruMhu967xtU5GevndehpOf0i8kZsne h1FDQRy1/37E10MdiABblarVV2vF+LTmtxyDNo49+MbzuZD0m+HGboAp0virI9o6Ap7V aL+w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e12si7108246eje.644.2020.12.19.23.18.05; Sat, 19 Dec 2020 23:18:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727129AbgLTHOf (ORCPT + 99 others); Sun, 20 Dec 2020 02:14:35 -0500 Received: from spam.zju.edu.cn ([61.164.42.155]:36276 "EHLO zju.edu.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726996AbgLTHOf (ORCPT ); Sun, 20 Dec 2020 02:14:35 -0500 X-Greylist: delayed 459 seconds by postgrey-1.27 at vger.kernel.org; Sun, 20 Dec 2020 02:14:31 EST Received: from localhost.localdomain (unknown [10.192.85.18]) by mail-app4 (Coremail) with SMTP id cS_KCgAHz3DF995fUqhSAA--.51071S4; Sun, 20 Dec 2020 15:05:47 +0800 (CST) From: Dinghao Liu To: dinghao.liu@zju.edu.cn, kjlu@umn.edu Cc: "David S. Miller" , linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] ide: pci: Fix memleak in ide_pci_init_two Date: Sun, 20 Dec 2020 15:05:40 +0800 Message-Id: <20201220070541.7515-1-dinghao.liu@zju.edu.cn> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: cS_KCgAHz3DF995fUqhSAA--.51071S4 X-Coremail-Antispam: 1UD129KBjvdXoWrKFyUCry5tF48GF1fJrWrZrb_yoW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kernel.org When do_ide_setup_pci_device() fails, host allocated by ide_host_alloc() may not have been freed, which leads to memleak. Signed-off-by: Dinghao Liu --- drivers/ide/setup-pci.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c index fdc8e813170c..c7da5368fcd4 100644 --- a/drivers/ide/setup-pci.c +++ b/drivers/ide/setup-pci.c @@ -586,7 +586,7 @@ int ide_pci_init_two(struct pci_dev *dev1, struct pci_dev *dev2, * do_ide_setup_pci_device() on the first device! */ if (ret < 0) - goto out_free_bars; + goto out_free_host; /* fixup IRQ */ if (ide_pci_is_in_compatibility_mode(pdev[i])) { @@ -597,11 +597,11 @@ int ide_pci_init_two(struct pci_dev *dev1, struct pci_dev *dev2, } ret = ide_host_register(host, d, hws); - if (ret) - ide_host_free(host); - else + if (!ret) goto out; +out_free_host: + ide_host_free(host); out_free_bars: i = n_ports / 2; while (i--) -- 2.17.1