Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3212240pxb; Sun, 7 Feb 2021 01:29:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJwd6XKosbliHKNMfFxg0PzJBbBPhieY5HUNpMRi/gJ7aRbEKG4uQ8aVmQszFADIoZ4YAyWA X-Received: by 2002:aa7:c0cd:: with SMTP id j13mr11898244edp.156.1612690181020; Sun, 07 Feb 2021 01:29:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612690181; cv=none; d=google.com; s=arc-20160816; b=SdQWaTZZB353vaTfIGkqxqwhN6/HzVy2CUZCKw01KBT34X39bSGdDxJds/h9ltpRE/ bOk/L51e8PbEABvMUfuKPWzAClB2TN9aJCFSKAzMIUFBvJRqEifCKCKQlqB/wcYG/wX3 5ofpR8X1NwXz880/pm7xmqvIdKqcWAlzLJ9lLYhH4Y0KznLUm7mtSqb3sID6OZcVtL8s 3Iq8Bs6XeXwfoi6+eWhXk0XuXO6/2kevTZIbho530ipe1xzxYg/C1pAr6qBLOj8CF6cv KAJ3l+7IVGQx6ztFqqtV288iB8eaXVnUnDUDsPkXd/HQXeu3gESHeNiMCfyaTDYaTYk3 8b9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=ZNmbbZFYDbaFi4NLw5eXaohvzl+TUqGncwQTQHjMm+8=; b=EvTzIEAHV7fVb2m5FfV8uJ6yoPeijZPS5lAEurgaklLFT5xwWJQguH97FH1myKlYwf 2ysi7GfMeSk3X3sw7tpSYmPLPnigguz9LoC5IUt9FdtewPixoHKtISUnzkB/hLLS3Lkq qBJXwS1jchj3CbhQRwrC3bn7YrRnoe+2xKn9vWlx9/Y/FcYFUS4ch4HKnygrTkDwT1lK GEL0jZLuKkfxVobSnpIbHLbb3H6P62FuBym8uzMnHgvw/VbbMmyh19LEPKQksZSQ1JMJ 7jdNX6GEofChBc2tmw87AmyXpm3TCA0XomV5mVM4tw7fd/0drAb6z/VZSbrz9QupcKUb trkA== ARC-Authentication-Results: i=1; mx.google.com; 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 hb20si6032652ejc.676.2021.02.07.01.29.13; Sun, 07 Feb 2021 01:29:41 -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; 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 S229797AbhBGJ0b (ORCPT + 99 others); Sun, 7 Feb 2021 04:26:31 -0500 Received: from jabberwock.ucw.cz ([46.255.230.98]:40816 "EHLO jabberwock.ucw.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229742AbhBGJ0K (ORCPT ); Sun, 7 Feb 2021 04:26:10 -0500 Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id 1C51D1C0B77; Sun, 7 Feb 2021 10:25:28 +0100 (CET) Date: Sun, 7 Feb 2021 10:25:27 +0100 From: Pavel Machek To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Pan Bian , Jakub Kicinski Subject: Re: [PATCH 5.4 01/32] net: dsa: bcm_sf2: put device node before return Message-ID: <20210207092527.GB32297@amd> References: <20210205140652.348864025@linuxfoundation.org> <20210205140652.414435105@linuxfoundation.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="3uo+9/B/ebqu+fSQ" Content-Disposition: inline In-Reply-To: <20210205140652.414435105@linuxfoundation.org> User-Agent: Mutt/1.5.23 (2014-03-12) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --3uo+9/B/ebqu+fSQ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! > From: Pan Bian >=20 > commit cf3c46631e1637582f517a574c77cd6c05793817 upstream. >=20 > Put the device node dn before return error code on failure path. This fixes one resource leak, but exposes next one: get_device() is not undone in the second error path and in the end of function. Best regards, Pavel > +++ b/drivers/net/dsa/bcm_sf2.c > @@ -421,15 +421,19 @@ static int bcm_sf2_mdio_register(struct > /* Find our integrated MDIO bus node */ > dn =3D of_find_compatible_node(NULL, NULL, "brcm,unimac-mdio"); > priv->master_mii_bus =3D of_mdio_find_bus(dn); > - if (!priv->master_mii_bus) > + if (!priv->master_mii_bus) { > + of_node_put(dn); > return -EPROBE_DEFER; > + } > =20 > get_device(&priv->master_mii_bus->dev); > priv->master_mii_dn =3D dn; > =20 > priv->slave_mii_bus =3D devm_mdiobus_alloc(ds->dev); > - if (!priv->slave_mii_bus) > + if (!priv->slave_mii_bus) { > + of_node_put(dn); > return -ENOMEM; > + } > =20 > priv->slave_mii_bus->priv =3D priv; > priv->slave_mii_bus->name =3D "sf2 slave mii"; >=20 --=20 http://www.livejournal.com/~pavelmachek --3uo+9/B/ebqu+fSQ Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAmAfsgcACgkQMOfwapXb+vKFfQCeJ3svL4kIy6zxFrOZoIvwQv27 jxsAoKdfe3FnCslEBpZLL3R87KpwUGE4 =LJc7 -----END PGP SIGNATURE----- --3uo+9/B/ebqu+fSQ--