diff options
author | Jens Taprogge <jens.taprogge@taprogge.org> | 2012-09-12 08:55:32 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-09-12 12:54:16 -0400 |
commit | b8d61d49b2437df3a0aef17d321948783d275bb3 (patch) | |
tree | eb0b00232739c2394e19593ae61e229ec007fe4e | |
parent | 699a89f1e291af0d47744200011d5c24d9e462a6 (diff) |
Staging: ipack/bridges/tpci200: RCU protect slot_irq pointers.
In tpci200_request_irq as well as tpci200_free_irq we set and unset the
pointer to struct slot_irq. This pointer is accessed in
tpci200_interrupt. To ensure that the pointer is not freed after it has
been fetched in tpci200_interrupt() it is now protected through RCU.
Signed-off-by: Jens Taprogge <jens.taprogge@taprogge.org>
Signed-off-by: Samuel Iglesias Gonsalvez <siglesias@igalia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/ipack/bridges/tpci200.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/staging/ipack/bridges/tpci200.c b/drivers/staging/ipack/bridges/tpci200.c index 24e2a119dd16..9ce577ab9437 100644 --- a/drivers/staging/ipack/bridges/tpci200.c +++ b/drivers/staging/ipack/bridges/tpci200.c | |||
@@ -132,10 +132,11 @@ static irqreturn_t tpci200_interrupt(int irq, void *dev_id) | |||
132 | 132 | ||
133 | if (status_reg & TPCI200_SLOT_INT_MASK) { | 133 | if (status_reg & TPCI200_SLOT_INT_MASK) { |
134 | /* callback to the IRQ handler for the corresponding slot */ | 134 | /* callback to the IRQ handler for the corresponding slot */ |
135 | rcu_read_lock(); | ||
135 | for (i = 0; i < TPCI200_NB_SLOT; i++) { | 136 | for (i = 0; i < TPCI200_NB_SLOT; i++) { |
136 | if (!(status_reg & ((TPCI200_A_INT0 | TPCI200_A_INT1) << (2*i)))) | 137 | if (!(status_reg & ((TPCI200_A_INT0 | TPCI200_A_INT1) << (2*i)))) |
137 | continue; | 138 | continue; |
138 | slot_irq = tpci200->slots[i].irq; | 139 | slot_irq = rcu_dereference(tpci200->slots[i].irq); |
139 | if (slot_irq) { | 140 | if (slot_irq) { |
140 | ret = tpci200_slot_irq(slot_irq); | 141 | ret = tpci200_slot_irq(slot_irq); |
141 | } else { | 142 | } else { |
@@ -147,6 +148,7 @@ static irqreturn_t tpci200_interrupt(int irq, void *dev_id) | |||
147 | TPCI200_INT0_EN | TPCI200_INT1_EN); | 148 | TPCI200_INT0_EN | TPCI200_INT1_EN); |
148 | } | 149 | } |
149 | } | 150 | } |
151 | rcu_read_unlock(); | ||
150 | } | 152 | } |
151 | 153 | ||
152 | return ret; | 154 | return ret; |
@@ -303,9 +305,9 @@ static int tpci200_free_irq(struct ipack_device *dev) | |||
303 | 305 | ||
304 | __tpci200_free_irq(tpci200, dev); | 306 | __tpci200_free_irq(tpci200, dev); |
305 | slot_irq = tpci200->slots[dev->slot].irq; | 307 | slot_irq = tpci200->slots[dev->slot].irq; |
306 | tpci200->slots[dev->slot].irq = NULL; | 308 | RCU_INIT_POINTER(tpci200->slots[dev->slot].irq, NULL); |
309 | synchronize_rcu(); | ||
307 | kfree(slot_irq); | 310 | kfree(slot_irq); |
308 | |||
309 | mutex_unlock(&tpci200->mutex); | 311 | mutex_unlock(&tpci200->mutex); |
310 | return 0; | 312 | return 0; |
311 | } | 313 | } |
@@ -490,7 +492,7 @@ static int tpci200_request_irq(struct ipack_device *dev, int vector, | |||
490 | slot_irq->arg = arg; | 492 | slot_irq->arg = arg; |
491 | slot_irq->holder = dev; | 493 | slot_irq->holder = dev; |
492 | 494 | ||
493 | tpci200->slots[dev->slot].irq = slot_irq; | 495 | rcu_assign_pointer(tpci200->slots[dev->slot].irq, slot_irq); |
494 | res = __tpci200_request_irq(tpci200, dev); | 496 | res = __tpci200_request_irq(tpci200, dev); |
495 | 497 | ||
496 | out_unlock: | 498 | out_unlock: |