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] [thread-next>] [day] [month] [year] [list]
Message-ID: <YcweTgHPyTa8ARF5@shinobu>
Date:   Wed, 29 Dec 2021 17:37:34 +0900
From:   William Breathitt Gray <vilhelm.gray@...il.com>
To:     Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
Cc:     Lars-Peter Clausen <lars@...afoo.de>, kernel@...gutronix.de,
        Jonathan Cameron <Jonathan.Cameron@...wei.com>,
        linux-iio@...r.kernel.org,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        linux-kernel@...r.kernel.org,
        Fabrice Gasnier <fabrice.gasnier@...s.st.com>,
        Maxime Coquelin <mcoquelin.stm32@...il.com>,
        Alexandre Torgue <alexandre.torgue@...s.st.com>,
        Benjamin Gaignard <benjamin.gaignard@...com>,
        linux-stm32@...md-mailman.stormreply.com,
        linux-arm-kernel@...ts.infradead.org
Subject: Re: [PATCH v2 20/23] counter: stm32-timer-cnt: Convert to new
 counter registration

On Mon, Dec 27, 2021 at 10:45:23AM +0100, Uwe Kleine-König wrote:
> This fixes device lifetime issues where it was possible to free a live
> struct device.
> 
> Fixes: ad29937e206f ("counter: Add STM32 Timer quadrature encoder")
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@...gutronix.de>

Acked-by: William Breathitt Gray <vilhelm.gray@...il.com>

> ---
>  drivers/counter/stm32-timer-cnt.c | 30 ++++++++++++++++++------------
>  1 file changed, 18 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/counter/stm32-timer-cnt.c b/drivers/counter/stm32-timer-cnt.c
> index 4b05b198a8d8..5779ae7c73cf 100644
> --- a/drivers/counter/stm32-timer-cnt.c
> +++ b/drivers/counter/stm32-timer-cnt.c
> @@ -29,7 +29,6 @@ struct stm32_timer_regs {
>  };
>  
>  struct stm32_timer_cnt {
> -	struct counter_device counter;
>  	struct regmap *regmap;
>  	struct clk *clk;
>  	u32 max_arr;
> @@ -317,31 +316,38 @@ static int stm32_timer_cnt_probe(struct platform_device *pdev)
>  	struct stm32_timers *ddata = dev_get_drvdata(pdev->dev.parent);
>  	struct device *dev = &pdev->dev;
>  	struct stm32_timer_cnt *priv;
> +	struct counter_device *counter;
> +	int ret;
>  
>  	if (IS_ERR_OR_NULL(ddata))
>  		return -EINVAL;
>  
> -	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
> -	if (!priv)
> +	counter = devm_counter_alloc(dev, sizeof(*priv));
> +	if (!counter)
>  		return -ENOMEM;
>  
> +	priv = counter_priv(counter);
> +
>  	priv->regmap = ddata->regmap;
>  	priv->clk = ddata->clk;
>  	priv->max_arr = ddata->max_arr;
>  
> -	priv->counter.name = dev_name(dev);
> -	priv->counter.parent = dev;
> -	priv->counter.ops = &stm32_timer_cnt_ops;
> -	priv->counter.counts = &stm32_counts;
> -	priv->counter.num_counts = 1;
> -	priv->counter.signals = stm32_signals;
> -	priv->counter.num_signals = ARRAY_SIZE(stm32_signals);
> -	priv->counter.priv = priv;
> +	counter->name = dev_name(dev);
> +	counter->parent = dev;
> +	counter->ops = &stm32_timer_cnt_ops;
> +	counter->counts = &stm32_counts;
> +	counter->num_counts = 1;
> +	counter->signals = stm32_signals;
> +	counter->num_signals = ARRAY_SIZE(stm32_signals);
>  
>  	platform_set_drvdata(pdev, priv);
>  
>  	/* Register Counter device */
> -	return devm_counter_register(dev, &priv->counter);
> +	ret = devm_counter_add(dev, counter);
> +	if (ret < 0)
> +		dev_err_probe(dev, ret, "Failed to add counter\n");
> +
> +	return ret;
>  }
>  
>  static int __maybe_unused stm32_timer_cnt_suspend(struct device *dev)
> -- 
> 2.33.0
> 

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