Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3929576pxu; Sun, 20 Dec 2020 22:33:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJwE7V1WZhccHZJOE686ZAbqTRYnJQtPGWr12UFaDO5cH7E/gWerbyMMWonQ37ZCuz4RzWXH X-Received: by 2002:a17:906:4050:: with SMTP id y16mr13744262ejj.537.1608532404734; Sun, 20 Dec 2020 22:33:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608532404; cv=none; d=google.com; s=arc-20160816; b=n8TLedv44hGR/BKXq5sBGyej068ssUwk8qsJOeZnR7AfwMAfHX9qm9O4N7qixbVfn6 OLiBXj3qD2Kjl4I+73UD3qTqzO7SFCPRwQyeJ7lqIisP324HdWue5vkvNUlSqQflGXZW 5niknjRtpcg3dB8LgzJSj7XWAEqjtA+iJjmhJtnGZ58RQMGa9DcB5j85uh83ba/Fu9+t bJ7UBdnXJRfEEuwx4/X/AkNLN9QGPDS2VTy7v5HqF/zikdgyqoQqmFkbenceMWALAJXL RjxE6+sBarhaegyaMwpMPWtJ7Dgn961upl1VUD/SF/3LZ+1ai4RsBdwWAJ78oSWrrmv3 VO7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=upGN1dBVZ/btBdBBPeURAqi5iKi4W8RMHZ52S9FrN+g=; b=C1o1pU138cBdxpT70SrqCsyLQ0ftmNyD5DVl9iaz15c37ARGG70gdKqf0JE0T2U+kW 4HWkYCLOhZWPZA6w76Zn1uRkcHOO5WuAJoPcPBfpwOAGhlPwBznPF1Pd3vUHDel4EMcA 0jVeRBMcsYArtshvLl55+2WWIfLq35sml6EwdERv3g8uaNO0zYlW9OwTijSd/W8MCo5J +fSYfpLWhiqokrp7AXvh4Y/JGBZM6pb5zLCyK6uLsJYXAzDZaSV7DFR5vIJ3tOkP/nm9 RdiTuOtTjP4pleOimaCcgK1FNl/bKvmLVb5kfDz1mrQiDTQv/ac6dlsYg7yCgFYjnu92 FILA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="f//lnvun"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ox26si9379717ejb.629.2020.12.20.22.33.02; Sun, 20 Dec 2020 22:33:24 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b="f//lnvun"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727891AbgLUGci (ORCPT + 99 others); Mon, 21 Dec 2020 01:32:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727211AbgLUGci (ORCPT ); Mon, 21 Dec 2020 01:32:38 -0500 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 506C2C0613D3; Sun, 20 Dec 2020 22:31:57 -0800 (PST) Received: by mail-ed1-x532.google.com with SMTP id c7so8503137edv.6; Sun, 20 Dec 2020 22:31:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=upGN1dBVZ/btBdBBPeURAqi5iKi4W8RMHZ52S9FrN+g=; b=f//lnvun2qaI2b2XF05irRBMFR0/xFM8ZlFjdmAkLPMpOeF8Pgv70DgDp8TbunYqZT +cv36wy/8zLg02Gtz12XmbbbuSuA28nxEDmJoiLwI3BTJgHYmRlj6knCWNDmtsnEjkPV RQcUhCMwt9qP8SJJ32kqOeYioj3UClqalDVGxsi5xKSRgL9R91ZSj0vyrGdt+mij3H1H vcPqc1tUeGT9OUpPtMhiKl8z0aOYEHE4gI197kA+svK5FJ5/Jfnk8PSzTEshQvpVhWbv et0gvNOXxXjSypfOvvbbCPxdvaYbNvV7B4mJeNJuq/dbHaf4sID+w5Wv6q8aKP5VH2hU DdtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=upGN1dBVZ/btBdBBPeURAqi5iKi4W8RMHZ52S9FrN+g=; b=NVyWdvDMn+XBvOlUxXsp0eo48f9XjrX23Z8hR31BA84l1DWTkxx3rtepS6RT8ZzeiT DWNejQ1CPf0IDfSFZTCYwu7sTTUOsXe3nhDdWStgQ4QG3l5oKkrqEjpd4upWiIjrLbJ3 XNLj4LCrHAxjMqDE1w2mtcRgCSft0NQ79U/AVwibDcnv4lOFUw7jKpZ4VWsuqL35vKr9 SXXGAAaGv4wciIv8EEH0D+j5/xhx/+k5soe1XCgzETJmI0+W3kyQG5r1uAAc3A30TEQj N2ipr0r/l8q49JC3aSw5ayDAxYVJUVam0GkzBQzcIekcAxGjybxE5gA1mH0lSbBRSytJ fDuw== X-Gm-Message-State: AOAM532ghJ6nMDsF0QgDh/Epy4NgSprzdbyYRqGSPfdv0HvreCXOxng2 uypH/MX1CDFlhe1Jc5SHWqyloQyIFqPmEw== X-Received: by 2002:a05:6512:368d:: with SMTP id d13mr5150213lfs.414.1608493836961; Sun, 20 Dec 2020 11:50:36 -0800 (PST) Received: from kari-VirtualBox (87-95-193-210.bb.dnainternet.fi. [87.95.193.210]) by smtp.gmail.com with ESMTPSA id k21sm1907262ljb.43.2020.12.20.11.50.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Dec 2020 11:50:36 -0800 (PST) Date: Sun, 20 Dec 2020 21:50:33 +0200 From: Kari Argillander To: Dinghao Liu Cc: kjlu@umn.edu, "David S. Miller" , linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] ide: pci: Fix memleak in ide_pci_init_two Message-ID: <20201220195033.due2e4ukijaah23a@kari-VirtualBox> References: <20201220070541.7515-1-dinghao.liu@zju.edu.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201220070541.7515-1-dinghao.liu@zju.edu.cn> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Dec 20, 2020 at 03:05:40PM +0800, Dinghao Liu wrote: > 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; Maybe if (ret) goto out_free_host; return 0; would be more clear here. But this is just small nit. > > +out_free_host: > + ide_host_free(host); > out_free_bars: > i = n_ports / 2; > while (i--)