Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp19739pxb; Fri, 15 Jan 2021 04:52:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJwzX1eAb8fCYKKFks4tWlBdYgZulSv9bQfLltGRPypj/BW+LHanU4IKbloukUQ4TsibbSOp X-Received: by 2002:a17:906:7b8d:: with SMTP id s13mr8525732ejo.479.1610715127769; Fri, 15 Jan 2021 04:52:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610715127; cv=none; d=google.com; s=arc-20160816; b=VW+oixj79wsJV5DiuNyVNuDor1kcZ2N2An46kpMHJsFwR7bW8c2jc5edYdQ8EGCCUK asg8GfSP1G9/h6MhfBXoEE0ln7N2bQrAm9UY5dzePCPa+91HCB8tlfN7X6RBV2YUJNNH 7kxZXQabU8BPUCzVBBSIXIZadygKnwXHJJvpv1ARAkJ6om1nVmdDnZEIP6zpbhu2v+xW CzMESPjk99YTVz0MZ/Tfubs4bf0dZyEv3D6iO6yIKwHOkvCbTL8eRLVZd9fm7IcP75hL T8XeviM46kdwYgwupbIge030rN54znyj83lHYeg7catv0mZVYLy02+9xxX8oalJOHlPY yqTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=h29JkW89EGsG5pjQ7T4j0E/QGm0xZR8nG/r5poiy3HQ=; b=SagrIQ4/LeoAzmLoNYRy+Y+EBW9rnarKidqm5cdfdHc32qxqS1GoCRmyacKTA441zE wXVnowD8NOjq8Tkr9c0/EVC9MAkBrtRYqYZ/+cdqJfS5/xxMnN/snsh4JmyADbO+2dkH ECug3wjU5B+LV8A59albQkadtJ4LJnDAMb6OjqJ6HeyUhJMVC9/nUpuI8MP3bjoxCwJ+ Uxi4EWDIGrAuREXW/0rTptvq5/07bRP372PEKF1t9z7183U0aETCo172fkfG0bQoyfnI FpViNhlgdB49chofBN2zcNhcqzhEc5FHQfBF7ZXgzBl7X93F7mHU9048oPeDf4u+lxQV 28+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WcADx9dc; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p12si3530312ejf.542.2021.01.15.04.51.44; Fri, 15 Jan 2021 04:52:07 -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=@linuxfoundation.org header.s=korg header.b=WcADx9dc; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732750AbhAOMvF (ORCPT + 99 others); Fri, 15 Jan 2021 07:51:05 -0500 Received: from mail.kernel.org ([198.145.29.99]:42222 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387778AbhAOMgC (ORCPT ); Fri, 15 Jan 2021 07:36:02 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id F07C622473; Fri, 15 Jan 2021 12:35:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610714147; bh=8X6I/2MBpox0hCLP6J9XLprleMfsCCAEUqUV+Fq+YEA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WcADx9dcP7m4u6wrOH6TUI6E5t8J26MQHpFSMLRl2q6nxtXmpIXKwkikxwsHYBF+Y 8tI6QTFL9otmCIwRXjO71nK1i1ty4NwmL5A+GFmzPkn6Tyu+1/9I2Y62BaOPRHHsTS ABblbRO3Y/cWBtfmQLm5HrB2Flg6uzF8UHR0iUiw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dinghao Liu , Lu Baolu , Will Deacon Subject: [PATCH 5.4 51/62] iommu/intel: Fix memleak in intel_irq_remapping_alloc Date: Fri, 15 Jan 2021 13:28:13 +0100 Message-Id: <20210115122000.855971473@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210115121958.391610178@linuxfoundation.org> References: <20210115121958.391610178@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dinghao Liu commit ff2b46d7cff80d27d82f7f3252711f4ca1666129 upstream. When irq_domain_get_irq_data() or irqd_cfg() fails at i == 0, data allocated by kzalloc() has not been freed before returning, which leads to memleak. Fixes: b106ee63abcc ("irq_remapping/vt-d: Enhance Intel IR driver to support hierarchical irqdomains") Signed-off-by: Dinghao Liu Acked-by: Lu Baolu Link: https://lore.kernel.org/r/20210105051837.32118-1-dinghao.liu@zju.edu.cn Signed-off-by: Will Deacon Signed-off-by: Greg Kroah-Hartman --- drivers/iommu/intel_irq_remapping.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/iommu/intel_irq_remapping.c +++ b/drivers/iommu/intel_irq_remapping.c @@ -1400,6 +1400,8 @@ static int intel_irq_remapping_alloc(str irq_data = irq_domain_get_irq_data(domain, virq + i); irq_cfg = irqd_cfg(irq_data); if (!irq_data || !irq_cfg) { + if (!i) + kfree(data); ret = -EINVAL; goto out_free_data; }