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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <YR+TQP3wWV+91fn2@orome.fritz.box>
Date:   Fri, 20 Aug 2021 13:34:24 +0200
From:   Thierry Reding <thierry.reding@...il.com>
To:     jing yangyang <cgel.zte@...il.com>, Mark Brown <broonie@...nel.org>
Cc:     JC Kuo <jckuo@...dia.com>, Kishon Vijay Abraham I <kishon@...com>,
        Vinod Koul <vkoul@...nel.org>,
        Jonathan Hunter <jonathanh@...dia.com>,
        linux-phy@...ts.infradead.org, linux-tegra@...r.kernel.org,
        linux-kernel@...r.kernel.org,
        jing yangyang <jing.yangyang@....com.cn>,
        Zeal Robot <zealci@....com.cn>
Subject: Re: [PATCH linux-next] phy/tegra: add put_device() after
 of_find_device_by_node()

On Thu, Aug 19, 2021 at 07:46:33PM -0700, jing yangyang wrote:
> This was found by coccicheck:
> ./drivers/phy/tegra/xusb-tegra210.c:3174: 2-8:ERROR:
> missing put_device;call of_find_device_by_node on line 3167,
> but without a corresponding object release within this function.
> 
> Reported-by: Zeal Robot <zealci@....com.cn>
> Signed-off-by: jing yangyang <jing.yangyang@....com.cn>
> ---
>  drivers/phy/tegra/xusb-tegra210.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/phy/tegra/xusb-tegra210.c b/drivers/phy/tegra/xusb-tegra210.c
> index eedfc7c..f26eb5a 100644
> --- a/drivers/phy/tegra/xusb-tegra210.c
> +++ b/drivers/phy/tegra/xusb-tegra210.c
> @@ -3170,8 +3170,10 @@ static int tegra210_utmi_port_reset(struct phy *phy)
>  		goto out;
>  	}
>  
> -	if (!platform_get_drvdata(pdev))
> +	if (!platform_get_drvdata(pdev)) {
> +		put_device(&pdev->dev);
>  		return ERR_PTR(-EPROBE_DEFER);
> +	}
>  
>  	padctl->regmap = dev_get_regmap(&pdev->dev, "usb_sleepwalk");
>  	if (!padctl->regmap)

I think we also need that put_device() after getting the regmap because
we loose the reference to the platform device after that.

On the other hand, I suppose we might have to hang on to the reference
until tegra210_xusb_padctl_remove() so that the platform device that the
regmap is provided by doesn't suddenly go away.

Mark, I couldn't find how the lifetime of regmaps is getting tracked.
dev_get_regmap() seems to only return a pointer to the regmap if it
exists, but doesn't actually increment a reference or anything. So do we
need to hold on to the struct device that we get it from until we no
longer need the reference? Or is there some other way to make sure the
regmap doesn't disappear on us?

Thierry

Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ