Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9883524ybi; Wed, 24 Jul 2019 11:39:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqwPhBQ4CSKa//nhtl4NC4lPuW85ec5vVWVpdvTIiyRbo9OPWA5Qxy09d0N4ksX0nHDf9U6M X-Received: by 2002:aa7:8193:: with SMTP id g19mr12336030pfi.16.1563993567020; Wed, 24 Jul 2019 11:39:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563993567; cv=none; d=google.com; s=arc-20160816; b=MgWg/MhvyhgowqYjZOsZhWk1Jyhb6AdNjSkFxZ+MUtr2plUbaMq3KAY+NKOztobdjP /HFAieGOjAZqb8BNNJjbgSn4IeuKIAeWIqdsw80NtcybQpBRy6JlNr7eAA0725PiH9Hi gCQTeGJULPGkiJqWSXOxR0pEMcFE0eezL59aesZ7fjKynotfTq2hMjcMvT/xugiGmga1 S7QJuSbCBlncPAx2PGEtRJCopKGJ0c5rij9NyVJprbpoU0eDMsfxMKeIS5MPDLeNb/jX 7OaCwlB+5ZqmxKb35rUg4Q3Gxk4/1OJVEjTm7oXOXAuA+U13CAA6bKMavPWtIsvcUaxL kj3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Lc0mkWPof9czpbEXb7cNSa0n2Wy9n9hEIeQ5R+nh1pA=; b=PbTi85fAPx8j6ARMAfpcvjpbBo+5u02MocfqJwrEg2ts3yHem/gLvJStbjgaMjIzz6 m9xwtN1cFrLa1vx9gU6ynczmD/taojSQRzZw/1Ls4jL/hmdhwJ+q9IgWR4vC9qee8rQN KMH5Pkdu8jjKm9if8JW8Vlr/8vI+BQJ/SBu9wWecy4c8m4t7akxf42kTcu3DRVDshSin 6k/gj0Yp3WXrMgHQfDlCvVuVBiUDeq6eVh3Sg/eQ7M0/XFlHSGjOAhEnskoiwTtFeqC5 HXLEXBqoxLKJIzq5kpsiJxOn/+OaANU/4Nxw1xYRIGOeyfKgNtrZ0NypiyEmVoNNYic+ ir0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=SZDJlr4X; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j191si17162741pgd.88.2019.07.24.11.39.11; Wed, 24 Jul 2019 11:39:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=SZDJlr4X; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728570AbfGXPrH (ORCPT + 99 others); Wed, 24 Jul 2019 11:47:07 -0400 Received: from heliosphere.sirena.org.uk ([172.104.155.198]:46810 "EHLO heliosphere.sirena.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727680AbfGXPrF (ORCPT ); Wed, 24 Jul 2019 11:47:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sirena.org.uk; s=20170815-heliosphere; h=In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Lc0mkWPof9czpbEXb7cNSa0n2Wy9n9hEIeQ5R+nh1pA=; b=SZDJlr4XdZYqHrB4X38XGVkwL ZdAtC7LvQC3zPXdxpHzoV2Qjr9g43GBFgkLxW0jKb6irlxrDYbH4Rj58dsKF8Te5kxVbh6n2Y10X2 Aip6ne8WDMDRPwMb4/Zto3ZR/a6n5o6+KQaT60VHroPJz6JvqoOV8hL1A0+KGlisMKBaU=; Received: from cpc102320-sgyl38-2-0-cust46.18-2.cable.virginm.net ([82.37.168.47] helo=ypsilon.sirena.org.uk) by heliosphere.sirena.org.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1hqJTr-000843-6B; Wed, 24 Jul 2019 15:47:03 +0000 Received: by ypsilon.sirena.org.uk (Postfix, from userid 1000) id EE34B2742B5D; Wed, 24 Jul 2019 16:47:01 +0100 (BST) Date: Wed, 24 Jul 2019 16:47:01 +0100 From: Mark Brown To: Nishka Dasgupta Cc: lgirdwood@gmail.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] regulator: of: Add of_node_put() before return in function Message-ID: <20190724154701.GA4524@sirena.org.uk> References: <20190724083231.10276-1-nishkadg.linux@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="EVF5PPMfhYS0aIcm" Content-Disposition: inline In-Reply-To: <20190724083231.10276-1-nishkadg.linux@gmail.com> X-Cookie: Matrimony is the root of all evil. User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --EVF5PPMfhYS0aIcm Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Jul 24, 2019 at 02:02:31PM +0530, Nishka Dasgupta wrote: > The local variable search in regulator_of_get_init_node takes the value > returned by either of_get_child_by_name or of_node_get, both of which > get a node. If this node is not put before returning, it could cause a > memory leak. Hence put search before a mid-loop return statement. > Issue found with Coccinelle. > - if (!strcmp(desc->of_match, name)) > + if (!strcmp(desc->of_match, name)) { > + of_node_put(search); > return of_node_get(child); > + } Why not just remove the extra of_node_get() and a comment explaining why it's not needed? --EVF5PPMfhYS0aIcm Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAl04fXIACgkQJNaLcl1U h9BzAQf/ZfWikyCjkNyf2y3H8tRh9hTsozRRPTDoKv5OA0kXowXCRiDKEAethice kw8J6gLF/zAM7fUi6I/ykCaUH1dZyj3a1y9CzA+Evr3GGd2YmzrgWWtdXlozaW1V lCz0csOupoL+snIKL1tC91H44TSha1DFUNPP7Uup358cR3kTrZMItdtU6fuUVxG1 QsIdMw4b5ug4tzvZCvt/ZVytb32z4KA3Uq3o2i0LeSvJ9HlhNgzoLD8ii62kt9v0 Y5owkpGEZx/4BuEuz+nWtElBr81jNnUASu3mmwCfUDY3520yteS12/y1wAY/s19/ u2AucDlyR4q5gq5UuuxoCYD8f/oh3w== =2N6g -----END PGP SIGNATURE----- --EVF5PPMfhYS0aIcm--