lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220111203333.507ec4f5@kicinski-fedora-PC1C0HJN.hsd1.ca.comcast.net>
Date:   Tue, 11 Jan 2022 20:33:33 -0800
From:   Jakub Kicinski <kuba@...nel.org>
To:     Miaoqian Lin <linmq006@...il.com>
Cc:     Yisen Zhuang <yisen.zhuang@...wei.com>,
        Salil Mehta <salil.mehta@...wei.com>,
        "David S. Miller" <davem@...emloft.net>,
        Yang Shen <shenyang39@...wei.com>,
        Yonglong Liu <liuyonglong@...wei.com>,
        Peng Li <lipeng321@...wei.com>,
        Matthias Brugger <mbrugger@...e.com>, netdev@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] net: hns: Fix missing put_device() call in
 hns_mac_register_phy

On Mon, 10 Jan 2022 06:40:29 +0000 Miaoqian Lin wrote:
> We need to drop the reference taken by hns_dsaf_find_platform_device
> Missing put_device() may cause refcount leak.
> 
> Fixes: 804ffe5c6197 ("net: hns: support deferred probe when no mdio")
> Signed-off-by: Miaoqian Lin <linmq006@...il.com>
> ---
>  drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
> index 7edf8569514c..7364e05487c7 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
> +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
> @@ -764,6 +764,7 @@ static int hns_mac_register_phy(struct hns_mac_cb *mac_cb)
>  		dev_err(mac_cb->dev,
>  			"mac%d mdio is NULL, dsaf will probe again later\n",
>  			mac_cb->mac_id);
> +		put_device(&pdev->dev);
>  		return -EPROBE_DEFER;
>  	}
>  

With more context:

@@ -755,24 +755,25 @@ static int hns_mac_register_phy(struct hns_mac_cb *mac_cb)
        pdev = hns_dsaf_find_platform_device(args.fwnode);
        if (!pdev) {
                dev_err(mac_cb->dev, "mac%d mdio pdev is NULL\n",
                        mac_cb->mac_id);
                return  -EINVAL;
        }
 
        mii_bus = platform_get_drvdata(pdev);
        if (!mii_bus) {
                dev_err(mac_cb->dev,
                        "mac%d mdio is NULL, dsaf will probe again later\n",
                        mac_cb->mac_id);
+               put_device(&pdev->dev);
                return -EPROBE_DEFER;
        }
 
        rc = hns_mac_register_phydev(mii_bus, mac_cb, addr);
        if (!rc)
                dev_dbg(mac_cb->dev, "mac%d register phy addr:%d\n",
                        mac_cb->mac_id, addr);
 
        return rc;
 }

Looks like if put_device() is missing it will also be missing in case
hns_mac_register_phydev() returns an error.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ