From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2AB3CC433E0 for ; Mon, 25 May 2020 13:10:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 04D7C2071A for ; Mon, 25 May 2020 13:10:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mg.codeaurora.org header.i=@mg.codeaurora.org header.b="NyibLdzb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403801AbgEYNKq (ORCPT ); Mon, 25 May 2020 09:10:46 -0400 Received: from mail26.static.mailgun.info ([104.130.122.26]:21549 "EHLO mail26.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390609AbgEYNKo (ORCPT ); Mon, 25 May 2020 09:10:44 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1590412243; h=Message-ID: References: In-Reply-To: Subject: Cc: To: From: Date: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=aF4c3OruqF54AfZxTOJsQX65D8kLmu7DWi/fjq3WVJo=; b=NyibLdzbwAJsdbUvk06k4BEgYyqv1hIKC6hiM7qHKfqWIXcUR68xbOrnSbUl6bnPLqFiXk7X mSE+D5yB9TJi1APoEi+0rxKYU7k64ytTG2qxvQU25O928nMn/b3bs+yWY5GWtRhwXFJxAWG1 zwtSu4YuVvIYCcbTDlR2kDC8LSQ= X-Mailgun-Sending-Ip: 104.130.122.26 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n02.prod.us-west-2.postgun.com with SMTP id 5ecbc3bc9d4cf4d3ef77c128 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Mon, 25 May 2020 13:10:20 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 273B3C433C9; Mon, 25 May 2020 13:10:20 +0000 (UTC) Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: saiprakash.ranjan) by smtp.codeaurora.org (Postfix) with ESMTPSA id 7D3D6C433C6; Mon, 25 May 2020 13:10:19 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Mon, 25 May 2020 18:40:19 +0530 From: Sai Prakash Ranjan To: Joerg Roedel Cc: Will Deacon , Joerg Roedel , linux-kernel@vger.kernel.org, Evan Green , Douglas Anderson , iommu@lists.linux-foundation.org, linux-arm-msm@vger.kernel.org, Robin Murphy , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH] iommu: Fix group refcount in iommu_alloc_default_domain() In-Reply-To: <20200525130253.GH5075@suse.de> References: <20200522130145.30067-1-saiprakash.ranjan@codeaurora.org> <20200525130253.GH5075@suse.de> Message-ID: <132bf1acfb685d34db9caef6f55265de@codeaurora.org> X-Sender: saiprakash.ranjan@codeaurora.org User-Agent: Roundcube Webmail/1.3.9 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Joerg, On 2020-05-25 18:32, Joerg Roedel wrote: > Hi, > > On Fri, May 22, 2020 at 06:31:45PM +0530, Sai Prakash Ranjan wrote: >> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c >> index a4c2f122eb8b..05f7b77c432f 100644 >> --- a/drivers/iommu/iommu.c >> +++ b/drivers/iommu/iommu.c >> @@ -1491,6 +1491,7 @@ static int iommu_alloc_default_domain(struct >> device *dev) >> { >> struct iommu_group *group; >> unsigned int type; >> + int ret; >> >> group = iommu_group_get(dev); >> if (!group) >> @@ -1501,7 +1502,11 @@ static int iommu_alloc_default_domain(struct >> device *dev) >> >> type = iommu_get_def_domain_type(dev); >> >> - return iommu_group_alloc_default_domain(dev->bus, group, type); >> + ret = iommu_group_alloc_default_domain(dev->bus, group, type); >> + >> + iommu_group_put(group); >> + >> + return ret; >> } >> >> /** > > Thanks for the report and the fix. I think it is better to fix this by > not taking a group reference in iommu_alloc_default_domain() at all and > pass group as a parameter. Please see the patch I just sent out. > Thanks for the patch, it looks like the right thing to do. Testing it out now. Thanks, Sai -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation