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: <87f34cb7-6cd2-32b4-7668-e4851e4788ff@broadcom.com>
Date:   Thu, 6 Jul 2023 16:02:39 -0700
From:   Scott Branden <scott.branden@...adcom.com>
To:     Chengfeng Ye <dg573847474@...il.com>, andi.shyti@...nel.org,
        rjui@...adcom.com, sbranden@...adcom.com, wsa@...nel.org
Cc:     bcm-kernel-feedback-list@...adcom.com, linux-i2c@...r.kernel.org,
        linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH RESEND] i2c: bcm-iproc: Fix bcm_iproc_i2c_isr deadlock
 issue

Some comments inline

On 2023-07-06 14:14, Chengfeng Ye wrote:
> iproc_i2c_rd_reg and iproc_i2c_wr_reg are called from both
> interrupt context (e.g. bcm_iproc_i2c_isr) and process context
> (e.g. bcm_iproc_i2c_suspend). Therefore, interrupts should be
> disabled to avoid potential deadlock. To prevent this scenario,
> use spin_lock_irqsave.
> 
Add Fixes: tag here.
> Signed-off-by: Chengfeng Ye <dg573847474@...il.com>
> ---
>   drivers/i2c/busses/i2c-bcm-iproc.c | 10 ++++++----
>   1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-bcm-iproc.c b/drivers/i2c/busses/i2c-bcm-iproc.c
> index 85d8a6b04885..d02245e4db8c 100644
> --- a/drivers/i2c/busses/i2c-bcm-iproc.c
> +++ b/drivers/i2c/busses/i2c-bcm-iproc.c
> @@ -233,13 +233,14 @@ static inline u32 iproc_i2c_rd_reg(struct bcm_iproc_i2c_dev *iproc_i2c,
>   				   u32 offset)
>   {
>   	u32 val;
> +	unsigned long flags;
>   
>   	if (iproc_i2c->idm_base) {
> -		spin_lock(&iproc_i2c->idm_lock);
> +		spin_lock_irqsave(&iproc_i2c->idm_lock, flags);
>   		writel(iproc_i2c->ape_addr_mask,
>   		       iproc_i2c->idm_base + IDM_CTRL_DIRECT_OFFSET);
>   		val = readl(iproc_i2c->base + offset);
> -		spin_unlock(&iproc_i2c->idm_lock);
> +		spin_unlock_irqrestore(&iproc_i2c->idm_lock, flags);
>   	} else {
>   		val = readl(iproc_i2c->base + offset);
>   	}
> @@ -250,12 +251,13 @@ static inline u32 iproc_i2c_rd_reg(struct bcm_iproc_i2c_dev *iproc_i2c,
>   static inline void iproc_i2c_wr_reg(struct bcm_iproc_i2c_dev *iproc_i2c,
>   				    u32 offset, u32 val)
>   {
> +	unsigned long flags;
Add newline after variable declarations.
>   	if (iproc_i2c->idm_base) {
> -		spin_lock(&iproc_i2c->idm_lock);
> +		spin_lock_irqsave(&iproc_i2c->idm_lock, flags);
>   		writel(iproc_i2c->ape_addr_mask,
>   		       iproc_i2c->idm_base + IDM_CTRL_DIRECT_OFFSET);
>   		writel(val, iproc_i2c->base + offset);
> -		spin_unlock(&iproc_i2c->idm_lock);
> +		spin_unlock_irqrestore(&iproc_i2c->idm_lock, flags);
>   	} else {
>   		writel(val, iproc_i2c->base + offset);
>   	}

Download attachment "smime.p7s" of type "application/pkcs7-signature" (4212 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ