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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5E10C433EF for ; Mon, 23 May 2022 11:54:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235118AbiEWLyP (ORCPT ); Mon, 23 May 2022 07:54:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235120AbiEWLyJ (ORCPT ); Mon, 23 May 2022 07:54:09 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A0E85133E for ; Mon, 23 May 2022 04:54:09 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CAA8E612CA for ; Mon, 23 May 2022 11:54:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 35D2DC385AA; Mon, 23 May 2022 11:54:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1653306848; bh=yiHuvRq2ifZnUcEmcstVnk0KFOc8FpIy8LiSvJGaPUs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=MBoIiS0IqElh+FJnYtAdIXyQJdqQ8pbXMPdfXmeNH2Sbrqx5nOeJSAV+V9pcOnl5X 7RkL/HuANJjhMo5PPFj3/y62N5fv2ld+1YvURco2jEDmndYGy1EpRcDc2UWHCQ1jue 5I9icP/Ho1+tq8VldMg0Ze4VSXUsb+oY94ot/fv7OlRixVkDYOOVoqWIjpVSNZlave XVmc7CBKq2BA+0cQrxa3TxJOX+FqlhFn9NwYbHEFYiQf4DD14xfdLijOho9S8AVdnD mjwDrMj5oB5kdQuE7I8/LnYUxGF+vrrsKX8Z1DaKHUFPjuYYMFtBuaFdyhHebZ5PMw mlMfQ0nFt7hAg== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1nt6dQ-00031b-De; Mon, 23 May 2022 13:54:04 +0200 Date: Mon, 23 May 2022 13:54:04 +0200 From: Johan Hovold To: cgel.zte@gmail.com Cc: joro@8bytes.org, will@kernel.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Minghao Chi , Zeal Robot Subject: Re: [PATCH] iommu/ipmmu-vmsa: Avoid leak OF node on error Message-ID: References: <20220523111145.2976-1-chi.minghao@zte.com.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220523111145.2976-1-chi.minghao@zte.com.cn> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 23, 2022 at 11:11:45AM +0000, cgel.zte@gmail.com wrote: > From: Minghao Chi > > The OF node should be put before returning error in ipmmu_init(), > otherwise node's refcount will be leaked. > > Reported-by: Zeal Robot > Signed-off-by: Minghao Chi > --- > drivers/iommu/ipmmu-vmsa.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c > index 8fdb84b3642b..f6440b106f46 100644 > --- a/drivers/iommu/ipmmu-vmsa.c > +++ b/drivers/iommu/ipmmu-vmsa.c > @@ -1179,11 +1179,10 @@ static int __init ipmmu_init(void) > return 0; > > np = of_find_matching_node(NULL, ipmmu_of_ids); > + of_node_put(np); > if (!np) > return 0; > > - of_node_put(np); > - > ret = platform_driver_register(&ipmmu_driver); > if (ret < 0) > return ret; NAK 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 Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C42AEC433F5 for ; Mon, 23 May 2022 11:54:13 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 66DBC60D75; Mon, 23 May 2022 11:54:13 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7g8bjhSRjg-P; Mon, 23 May 2022 11:54:12 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id 5FF9560BB0; Mon, 23 May 2022 11:54:12 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 2DC0AC0032; Mon, 23 May 2022 11:54:12 +0000 (UTC) Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 15FD1C002D for ; Mon, 23 May 2022 11:54:11 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 0306F60D75 for ; Mon, 23 May 2022 11:54:11 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7W65iOUf_57o for ; Mon, 23 May 2022 11:54:10 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by smtp3.osuosl.org (Postfix) with ESMTPS id 5E0E860BB0 for ; Mon, 23 May 2022 11:54:10 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id F0A82612DD; Mon, 23 May 2022 11:54:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 35D2DC385AA; Mon, 23 May 2022 11:54:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1653306848; bh=yiHuvRq2ifZnUcEmcstVnk0KFOc8FpIy8LiSvJGaPUs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=MBoIiS0IqElh+FJnYtAdIXyQJdqQ8pbXMPdfXmeNH2Sbrqx5nOeJSAV+V9pcOnl5X 7RkL/HuANJjhMo5PPFj3/y62N5fv2ld+1YvURco2jEDmndYGy1EpRcDc2UWHCQ1jue 5I9icP/Ho1+tq8VldMg0Ze4VSXUsb+oY94ot/fv7OlRixVkDYOOVoqWIjpVSNZlave XVmc7CBKq2BA+0cQrxa3TxJOX+FqlhFn9NwYbHEFYiQf4DD14xfdLijOho9S8AVdnD mjwDrMj5oB5kdQuE7I8/LnYUxGF+vrrsKX8Z1DaKHUFPjuYYMFtBuaFdyhHebZ5PMw mlMfQ0nFt7hAg== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1nt6dQ-00031b-De; Mon, 23 May 2022 13:54:04 +0200 Date: Mon, 23 May 2022 13:54:04 +0200 From: Johan Hovold To: cgel.zte@gmail.com Subject: Re: [PATCH] iommu/ipmmu-vmsa: Avoid leak OF node on error Message-ID: References: <20220523111145.2976-1-chi.minghao@zte.com.cn> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220523111145.2976-1-chi.minghao@zte.com.cn> Cc: linux-kernel@vger.kernel.org, Minghao Chi , iommu@lists.linux-foundation.org, will@kernel.org, Zeal Robot X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" On Mon, May 23, 2022 at 11:11:45AM +0000, cgel.zte@gmail.com wrote: > From: Minghao Chi > > The OF node should be put before returning error in ipmmu_init(), > otherwise node's refcount will be leaked. > > Reported-by: Zeal Robot > Signed-off-by: Minghao Chi > --- > drivers/iommu/ipmmu-vmsa.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c > index 8fdb84b3642b..f6440b106f46 100644 > --- a/drivers/iommu/ipmmu-vmsa.c > +++ b/drivers/iommu/ipmmu-vmsa.c > @@ -1179,11 +1179,10 @@ static int __init ipmmu_init(void) > return 0; > > np = of_find_matching_node(NULL, ipmmu_of_ids); > + of_node_put(np); > if (!np) > return 0; > > - of_node_put(np); > - > ret = platform_driver_register(&ipmmu_driver); > if (ret < 0) > return ret; NAK _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu