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: <YcwcZMO53T+EVlLM@shinobu>
Date:   Wed, 29 Dec 2021 17:29:24 +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,
        Jarkko Nikula <jarkko.nikula@...ux.intel.com>,
        "Felipe Balbi (Intel)" <balbi@...nel.org>,
        Raymond Tan <raymond.tan@...el.com>
Subject: Re: [PATCH v2 17/23] counter: intel-qep: Convert to new counter
 registration

On Mon, Dec 27, 2021 at 10:45:20AM +0100, Uwe Kleine-König wrote:
> This fixes device lifetime issues where it was possible to free a live
> struct device.
> 
> Fixes: b711f687a1c1 ("counter: Add support for Intel Quadrature Encoder Peripheral")
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@...gutronix.de>

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

> ---
>  drivers/counter/intel-qep.c | 28 ++++++++++++++++------------
>  1 file changed, 16 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/counter/intel-qep.c b/drivers/counter/intel-qep.c
> index 8f84a48508ac..47a6a9dfc9e8 100644
> --- a/drivers/counter/intel-qep.c
> +++ b/drivers/counter/intel-qep.c
> @@ -63,7 +63,6 @@
>  #define INTEL_QEP_CLK_PERIOD_NS		10
>  
>  struct intel_qep {
> -	struct counter_device counter;
>  	struct mutex lock;
>  	struct device *dev;
>  	void __iomem *regs;
> @@ -392,14 +391,16 @@ static struct counter_count intel_qep_counter_count[] = {
>  
>  static int intel_qep_probe(struct pci_dev *pci, const struct pci_device_id *id)
>  {
> +	struct counter_device *counter;
>  	struct intel_qep *qep;
>  	struct device *dev = &pci->dev;
>  	void __iomem *regs;
>  	int ret;
>  
> -	qep = devm_kzalloc(dev, sizeof(*qep), GFP_KERNEL);
> -	if (!qep)
> +	counter = devm_counter_alloc(dev, sizeof(*qep));
> +	if (!counter)
>  		return -ENOMEM;
> +	qep = counter_priv(counter);
>  
>  	ret = pcim_enable_device(pci);
>  	if (ret)
> @@ -422,20 +423,23 @@ static int intel_qep_probe(struct pci_dev *pci, const struct pci_device_id *id)
>  	intel_qep_init(qep);
>  	pci_set_drvdata(pci, qep);
>  
> -	qep->counter.name = pci_name(pci);
> -	qep->counter.parent = dev;
> -	qep->counter.ops = &intel_qep_counter_ops;
> -	qep->counter.counts = intel_qep_counter_count;
> -	qep->counter.num_counts = ARRAY_SIZE(intel_qep_counter_count);
> -	qep->counter.signals = intel_qep_signals;
> -	qep->counter.num_signals = ARRAY_SIZE(intel_qep_signals);
> -	qep->counter.priv = qep;
> +	counter->name = pci_name(pci);
> +	counter->parent = dev;
> +	counter->ops = &intel_qep_counter_ops;
> +	counter->counts = intel_qep_counter_count;
> +	counter->num_counts = ARRAY_SIZE(intel_qep_counter_count);
> +	counter->signals = intel_qep_signals;
> +	counter->num_signals = ARRAY_SIZE(intel_qep_signals);
>  	qep->enabled = false;
>  
>  	pm_runtime_put(dev);
>  	pm_runtime_allow(dev);
>  
> -	return devm_counter_register(&pci->dev, &qep->counter);
> +	ret = devm_counter_add(&pci->dev, counter);
> +	if (ret < 0)
> +		return dev_err_probe(&pci->dev, ret, "Failed to add counter\n");
> +
> +	return 0;
>  }
>  
>  static void intel_qep_remove(struct pci_dev *pci)
> -- 
> 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