Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp669345ybg; Mon, 1 Jun 2020 11:14:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9O4Uvux9B3pRN44p2G1Z8OyfBX2zi2Pf9S6p2Ctfrv8kfqagLVlS7IpPcCRAr5vsBZwIG X-Received: by 2002:a17:906:f115:: with SMTP id gv21mr14432402ejb.340.1591035241663; Mon, 01 Jun 2020 11:14:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591035241; cv=none; d=google.com; s=arc-20160816; b=VYUjZFhr8IuQ/G2kmOsEgsN+dPn0xc9vV/kJz8nxsdZtxJHq+Kdy7treoYaQU32SzO RBbex+w3ObxrcpROoWqtuI48MveubgolYgRtWk8fQ26k+qrUN7JX/HypHtUJouhT6YB3 io9hy/HeK6Sxgm9R5WPAP9sHOLpLl73nuSZxnS9YqCDQBmMALusJPjGtpveM0Onpt5Oc ejtJ4w1bDT8Tdnpurdn04aC+2SNPeogU066PVzoucM3rJ08CKx0Bws/12805bb2mepmi 2bRH/pZ0CtBmhf8ABWb/GfjvUv3qjN7SmW35a2CiQcL+E6tE3brNom4yudVhw/ZDl2Wu C6Zg== 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:dkim-signature; bh=t3/ZjG39IgXRF+pMvhzx/m6NU0KF9+nr82fLPWyxiTI=; b=07OkTAOEA3RZpTW3alXRl84Z8K5IF6N6H+Ocbbcxk4pGPmRcybHSwfj6C5KQW8AuCT Yxy7lY9KxsP68uo/+H6iAWAzSN11BD14Rlq5DFozkgN/3bQtF2d0sAgsJIIJuTrPwMNK l6Qyq6Lt2PtkTrgt43lxGGzJc8DDcLQZGpsH5KcYn2O3wCPqgf+JZZuV1DQ4LfdF4pb3 NNP2ryZA9ruRcEYR9xB67TGtLmNrwOBMgq6fz+FoNqO3fHW/sUJnL4McEn85ImNCvGSC y1UqSWD/pZ91D6GqyyCFN98JIgXask7bNNth/9GJnMzJL6rVWI5fcURaaXxQc5+gqBoZ FYUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=igZRWJb+; 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 v13si108907ejx.703.2020.06.01.11.13.37; Mon, 01 Jun 2020 11:14:01 -0700 (PDT) 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=@kernel.org header.s=default header.b=igZRWJb+; 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 S1731079AbgFASLM (ORCPT + 99 others); Mon, 1 Jun 2020 14:11:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:57948 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731039AbgFASK4 (ORCPT ); Mon, 1 Jun 2020 14:10:56 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2832320825; Mon, 1 Jun 2020 18:10:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591035055; bh=QrrXMRRBJoj5LvQo5PKvhynnLM2/nBp79vS5vFCcUbI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=igZRWJb+W/OpbLr1S80FbEYaOhobGnCDvhRikdelaSZXG/hwbCPtdL1NzQDgKhIyX fvo7xmfXywgTOOAKO1HCkku7rhS1Tn6K8G3obJwR7s0UPc3t2t3/+j4EjU/Hwq9YJt +muAyapy/mr/zgt8c257+BM8HI/lgDOqbwZfClVc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Qiushi Wu , Joerg Roedel , Sasha Levin Subject: [PATCH 5.4 105/142] iommu: Fix reference count leak in iommu_group_alloc. Date: Mon, 1 Jun 2020 19:54:23 +0200 Message-Id: <20200601174048.846732892@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200601174037.904070960@linuxfoundation.org> References: <20200601174037.904070960@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Qiushi Wu [ Upstream commit 7cc31613734c4870ae32f5265d576ef296621343 ] kobject_init_and_add() takes reference even when it fails. Thus, when kobject_init_and_add() returns an error, kobject_put() must be called to properly clean up the kobject. Fixes: d72e31c93746 ("iommu: IOMMU Groups") Signed-off-by: Qiushi Wu Link: https://lore.kernel.org/r/20200527210020.6522-1-wu000273@umn.edu Signed-off-by: Joerg Roedel Signed-off-by: Sasha Levin --- drivers/iommu/iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index cd3c0ea56657..9d7232e26ecf 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -492,7 +492,7 @@ struct iommu_group *iommu_group_alloc(void) NULL, "%d", group->id); if (ret) { ida_simple_remove(&iommu_group_ida, group->id); - kfree(group); + kobject_put(&group->kobj); return ERR_PTR(ret); } -- 2.25.1