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] [day] [month] [year] [list]
Message-ID: <20200629223004.GC3800@piout.net>
Date:   Tue, 30 Jun 2020 00:30:04 +0200
From:   Alexandre Belloni <alexandre.belloni@...tlin.com>
To:     Michał Mirosław <mirq-linux@...e.qmqm.pl>
Cc:     Nicolas Ferre <nicolas.ferre@...rochip.com>,
        Arnd Bergmann <arnd@...db.de>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Ludovic Desroches <ludovic.desroches@...rochip.com>,
        linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] misc: atmel-ssc: lock with mutex instead of spinlock

On 24/06/2020 13:35:41+0200, Michał Mirosław wrote:
> Uninterruptible context is not needed in the driver and causes lockdep
> warning because of mutex taken in of_alias_get_id(). Convert the lock to
> mutex to avoid the issue.
> 
> Cc: stable@...r.kernel.org
> Fixes: 099343c64e16 ("ARM: at91: atmel-ssc: add device tree support")
> Signed-off-by: Michał Mirosław <mirq-linux@...e.qmqm.pl>
Acked-by: Alexandre Belloni <alexandre.belloni@...tlin.com>

> ---
>  v2: rebased onto v5.7.5, added Fixes tag
> ---
>  drivers/misc/atmel-ssc.c | 24 ++++++++++++------------
>  1 file changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/misc/atmel-ssc.c b/drivers/misc/atmel-ssc.c
> index ab4144ea1f11..d6cd5537126c 100644
> --- a/drivers/misc/atmel-ssc.c
> +++ b/drivers/misc/atmel-ssc.c
> @@ -10,7 +10,7 @@
>  #include <linux/clk.h>
>  #include <linux/err.h>
>  #include <linux/io.h>
> -#include <linux/spinlock.h>
> +#include <linux/mutex.h>
>  #include <linux/atmel-ssc.h>
>  #include <linux/slab.h>
>  #include <linux/module.h>
> @@ -20,7 +20,7 @@
>  #include "../../sound/soc/atmel/atmel_ssc_dai.h"
>  
>  /* Serialize access to ssc_list and user count */
> -static DEFINE_SPINLOCK(user_lock);
> +static DEFINE_MUTEX(user_lock);
>  static LIST_HEAD(ssc_list);
>  
>  struct ssc_device *ssc_request(unsigned int ssc_num)
> @@ -28,7 +28,7 @@ struct ssc_device *ssc_request(unsigned int ssc_num)
>  	int ssc_valid = 0;
>  	struct ssc_device *ssc;
>  
> -	spin_lock(&user_lock);
> +	mutex_lock(&user_lock);
>  	list_for_each_entry(ssc, &ssc_list, list) {
>  		if (ssc->pdev->dev.of_node) {
>  			if (of_alias_get_id(ssc->pdev->dev.of_node, "ssc")
> @@ -44,18 +44,18 @@ struct ssc_device *ssc_request(unsigned int ssc_num)
>  	}
>  
>  	if (!ssc_valid) {
> -		spin_unlock(&user_lock);
> +		mutex_unlock(&user_lock);
>  		pr_err("ssc: ssc%d platform device is missing\n", ssc_num);
>  		return ERR_PTR(-ENODEV);
>  	}
>  
>  	if (ssc->user) {
> -		spin_unlock(&user_lock);
> +		mutex_unlock(&user_lock);
>  		dev_dbg(&ssc->pdev->dev, "module busy\n");
>  		return ERR_PTR(-EBUSY);
>  	}
>  	ssc->user++;
> -	spin_unlock(&user_lock);
> +	mutex_unlock(&user_lock);
>  
>  	clk_prepare(ssc->clk);
>  
> @@ -67,14 +67,14 @@ void ssc_free(struct ssc_device *ssc)
>  {
>  	bool disable_clk = true;
>  
> -	spin_lock(&user_lock);
> +	mutex_lock(&user_lock);
>  	if (ssc->user)
>  		ssc->user--;
>  	else {
>  		disable_clk = false;
>  		dev_dbg(&ssc->pdev->dev, "device already free\n");
>  	}
> -	spin_unlock(&user_lock);
> +	mutex_unlock(&user_lock);
>  
>  	if (disable_clk)
>  		clk_unprepare(ssc->clk);
> @@ -237,9 +237,9 @@ static int ssc_probe(struct platform_device *pdev)
>  		return -ENXIO;
>  	}
>  
> -	spin_lock(&user_lock);
> +	mutex_lock(&user_lock);
>  	list_add_tail(&ssc->list, &ssc_list);
> -	spin_unlock(&user_lock);
> +	mutex_unlock(&user_lock);
>  
>  	platform_set_drvdata(pdev, ssc);
>  
> @@ -258,9 +258,9 @@ static int ssc_remove(struct platform_device *pdev)
>  
>  	ssc_sound_dai_remove(ssc);
>  
> -	spin_lock(&user_lock);
> +	mutex_lock(&user_lock);
>  	list_del(&ssc->list);
> -	spin_unlock(&user_lock);
> +	mutex_unlock(&user_lock);
>  
>  	return 0;
>  }
> -- 
> 2.20.1
> 

-- 
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ