Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp33530pxb; Fri, 15 Jan 2021 05:12:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJwyii81HxyUoxw9FeggBm4g2eaw20QK0Vu+n0c6oZ5FrtL+35YV5wwWqmMn21k0VGcreH9/ X-Received: by 2002:a05:6402:697:: with SMTP id f23mr9784501edy.318.1610716354728; Fri, 15 Jan 2021 05:12:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610716354; cv=none; d=google.com; s=arc-20160816; b=CyKalqGeJJOdLS7AU9OcF517Ki/BP/GzK5fGIh6e1Nz/kHvxqeIpAygpvu4SJOKcTZ B0+FcQsefK1ohikOsiC/WbU32fUOAVkJ4oN5u1lXCjBjwtCQ8LiFenA0ALfPo9cLy3sR 0JBVGFESH92HggvQ3CVsdF3H3EAMBUZaGHVcn0xdRA2DLu914ujg1PJSCJUSV9jzzKyr 4ns9GAl99BBabc0Q7wA2nn7JY30dqJq0qSCd1hNbHbIgj+rzWKjLjIdKVb/s5D0ItQww X8gwVFU+NL4qa9FXRvDDXyiyHjXqLs2RoGXzOgwyZJn3NFTKq9VExJupBC8a6837pNQk 4RHQ== 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=h7tx/u4UB6/DRdGjteTPc4ajpdOpm4nMSQsDYycrWks=; b=T7Y6SJw5vC8cFWuQCMWHCYKlGU9zvOSpJqBdlTBMHr//GStO2njs+RuOcPlchnjL0A FlTY/Md6FOk0PnMRnICHSsOIIvmdlCyA7jAv/UFtGtIsRbPOJL6FWhPhahwoIk448yvl aL9qxgEit/0lRzYH4JJIDhEzY6cJCV+BJCopH0TM1BGfjZOVxdntP6sH3bkglL4Z9Nwg P51Jm9ADlrSDdm5u3a+SeyOXMkbIMvWUblzyPgM2Xm075oF9hEjOZGWWyEXEtMRduiDG lywbcp33RHKm1M6CeIeDdY888RGLT7etSqtQzEWA5YjBKaY0Dy3e2BTaYMUayoDwYPQx toyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JJkMLlxg; 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 dc14si238863ejb.161.2021.01.15.05.12.08; Fri, 15 Jan 2021 05:12:34 -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=JJkMLlxg; 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 S2387608AbhAONIv (ORCPT + 99 others); Fri, 15 Jan 2021 08:08:51 -0500 Received: from mail.kernel.org ([198.145.29.99]:36294 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732131AbhAOMal (ORCPT ); Fri, 15 Jan 2021 07:30:41 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id CBB2E23136; Fri, 15 Jan 2021 12:29:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610713773; bh=7DhH4CeaiM1Ol8TRHyRqIFvNkZi+WpYGPYti91uLLGk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JJkMLlxgxY5uqLvL0Z+tNgZajfFSohSUpTRAn3jPbDxn5wWpk45AzIcG7tOWnSbHy dHnV8gfOM8WiZmDIcrha1TTvfgtNvOkXsCK3FGTxWgE/rARY16tKUS5tiysP3gaKML c+TVyOwwTLmGjRSx/CZi64i2WJ1fKXmK9QL+n0fU= 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 4.4 16/18] iommu/intel: Fix memleak in intel_irq_remapping_alloc Date: Fri, 15 Jan 2021 13:27:44 +0100 Message-Id: <20210115121955.909084929@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210115121955.112329537@linuxfoundation.org> References: <20210115121955.112329537@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 @@ -1350,6 +1350,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; }