Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1223108 > unrolled thread

[PATCH] irda: ali-ircc: Fix deadlock in ali_ircc_sir_change_speed()

Started byAlexey Khoroshilov <khoroshilov@ispras.ru>
First post2015-09-11 23:40 +0200
Last post2015-09-12 01:20 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] irda: ali-ircc: Fix deadlock in ali_ircc_sir_change_speed() Alexey Khoroshilov <khoroshilov@ispras.ru> - 2015-09-11 23:40 +0200
    Re: [PATCH] irda: ali-ircc: Fix deadlock in  ali_ircc_sir_change_speed() David Miller <davem@davemloft.net> - 2015-09-12 01:20 +0200

#1223108 — [PATCH] irda: ali-ircc: Fix deadlock in ali_ircc_sir_change_speed()

FromAlexey Khoroshilov <khoroshilov@ispras.ru>
Date2015-09-11 23:40 +0200
Subject[PATCH] irda: ali-ircc: Fix deadlock in ali_ircc_sir_change_speed()
Message-ID<q7Ed3-5uE-7@gated-at.bofh.it>
ali_ircc_sir_change_speed() is always called with self->lock held,
so acquiring the lock inside it leads to unavoidable deadlock.

Call graph:
ali_ircc_sir_change_speed() is called from ali_ircc_change_speed()
  ali_ircc_fir_hard_xmit() under spin_lock_irqsave(&self->lock, flags);
  ali_ircc_sir_hard_xmit() under spin_lock_irqsave(&self->lock, flags);
  ali_ircc_net_ioctl() under spin_lock_irqsave(&self->lock, flags);
  ali_ircc_dma_xmit_complete()
    ali_ircc_fir_interrupt()
      ali_ircc_interrupt() under spin_lock(&self->lock);
  ali_ircc_sir_write_wakeup()
    ali_ircc_sir_interrupt()
      ali_ircc_interrupt() under spin_lock(&self->lock);

The patch removes spin_lock/unlock from ali_ircc_sir_change_speed().

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
---
 drivers/net/irda/ali-ircc.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/drivers/net/irda/ali-ircc.c b/drivers/net/irda/ali-ircc.c
index 58ae11a14bb6..64bb44d5d867 100644
--- a/drivers/net/irda/ali-ircc.c
+++ b/drivers/net/irda/ali-ircc.c
@@ -1031,7 +1031,6 @@ static void ali_ircc_fir_change_speed(struct ali_ircc_cb *priv, __u32 baud)
 static void ali_ircc_sir_change_speed(struct ali_ircc_cb *priv, __u32 speed)
 {
 	struct ali_ircc_cb *self = priv;
-	unsigned long flags;
 	int iobase; 
 	int fcr;    /* FIFO control reg */
 	int lcr;    /* Line control reg */
@@ -1061,8 +1060,6 @@ static void ali_ircc_sir_change_speed(struct ali_ircc_cb *priv, __u32 speed)
 	/* Update accounting for new speed */
 	self->io.speed = speed;
 
-	spin_lock_irqsave(&self->lock, flags);
-
 	divisor = 115200/speed;
 	
 	fcr = UART_FCR_ENABLE_FIFO;
@@ -1089,9 +1086,6 @@ static void ali_ircc_sir_change_speed(struct ali_ircc_cb *priv, __u32 speed)
 	/* without this, the connection will be broken after come back from FIR speed,
 	   but with this, the SIR connection is harder to established */
 	outb((UART_MCR_DTR | UART_MCR_RTS | UART_MCR_OUT2), iobase+UART_MCR);
-	
-	spin_unlock_irqrestore(&self->lock, flags);
-	
 }
 
 static void ali_ircc_change_dongle_speed(struct ali_ircc_cb *priv, int speed)
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1223244 — Re: [PATCH] irda: ali-ircc: Fix deadlock in ali_ircc_sir_change_speed()

FromDavid Miller <davem@davemloft.net>
Date2015-09-12 01:20 +0200
SubjectRe: [PATCH] irda: ali-ircc: Fix deadlock in ali_ircc_sir_change_speed()
Message-ID<q7FLR-7Un-43@gated-at.bofh.it>
In reply to#1223108
From: Alexey Khoroshilov <khoroshilov@ispras.ru>
Date: Sat, 12 Sep 2015 00:34:48 +0300

> ali_ircc_sir_change_speed() is always called with self->lock held,
> so acquiring the lock inside it leads to unavoidable deadlock.
> 
> Call graph:
> ali_ircc_sir_change_speed() is called from ali_ircc_change_speed()
>   ali_ircc_fir_hard_xmit() under spin_lock_irqsave(&self->lock, flags);
>   ali_ircc_sir_hard_xmit() under spin_lock_irqsave(&self->lock, flags);
>   ali_ircc_net_ioctl() under spin_lock_irqsave(&self->lock, flags);
>   ali_ircc_dma_xmit_complete()
>     ali_ircc_fir_interrupt()
>       ali_ircc_interrupt() under spin_lock(&self->lock);
>   ali_ircc_sir_write_wakeup()
>     ali_ircc_sir_interrupt()
>       ali_ircc_interrupt() under spin_lock(&self->lock);
> 
> The patch removes spin_lock/unlock from ali_ircc_sir_change_speed().
> 
> Found by Linux Driver Verification project (linuxtesting.org).
> 
> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>

Looks good, applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web