From: Stefani Seibold <stefani@seibold.net>
To: linux-kernel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
Mauro Carvalho Chehab <mchehab@infradead.org>,
Andy Walls <awalls@radix.net>,
Linux Media Mailing List <linux-media@vger.kernel.org>
Subject: [patch] media video cx23888 driver: fix possible races using new kfifo_API kfifo_reset()
Date: Fri, 18 Dec 2009 23:21:10 +0100 [thread overview]
Message-ID: <1261174870.13019.24.camel@wall-e> (raw)
Fix the cx23888 driver to use the new kfifo API. Using kfifo_reset() may
result in a possible race conditions. This patch fix it by using
spinlock around the kfifo_reset() function.
The patch-set is against mm tree from 11-Dec-2009
Greetings,
Stefani
Signed-off-by: Stefani Seibold <stefani@seibold.net>
---
cx23888-ir.c | 9 +++++++++
1 file changed, 9 insertions(+)
--- mmotm.orig/drivers/media/video/cx23885/cx23888-ir.c 2009-12-18 22:57:13.588337402 +0100
+++ mmotm/drivers/media/video/cx23885/cx23888-ir.c 2009-12-18 23:15:14.651365720 +0100
@@ -519,6 +519,7 @@ static int cx23888_ir_irq_handler(struct
{
struct cx23888_ir_state *state = to_state(sd);
struct cx23885_dev *dev = state->dev;
+ unsigned long flags;
u32 cntrl = cx23888_ir_read4(dev, CX23888_IR_CNTRL_REG);
u32 irqen = cx23888_ir_read4(dev, CX23888_IR_IRQEN_REG);
@@ -629,8 +630,11 @@ static int cx23888_ir_irq_handler(struct
cx23888_ir_write4(dev, CX23888_IR_CNTRL_REG, cntrl);
*handled = true;
}
+
+ spin_lock_irqsave(&state->rx_kfifo_lock, flags);
if (kfifo_len(&state->rx_kfifo) >= CX23888_IR_RX_KFIFO_SIZE / 2)
events |= V4L2_SUBDEV_IR_RX_FIFO_SERVICE_REQ;
+ spin_unlock_irqrestore(&state->rx_kfifo_lock, flags);
if (events)
v4l2_subdev_notify(sd, V4L2_SUBDEV_IR_RX_NOTIFY, &events);
@@ -783,7 +787,12 @@ static int cx23888_ir_rx_s_parameters(st
o->interrupt_enable = p->interrupt_enable;
o->enable = p->enable;
if (p->enable) {
+ unsigned long flags;
+
+ spin_lock_irqsave(&state->rx_kfifo_lock, flags);
kfifo_reset(&state->rx_kfifo);
+ /* reset tx_fifo too if there is one... */
+ spin_unlock_irqrestore(&state->rx_kfifo_lock, flags);
if (p->interrupt_enable)
irqenable_rx(dev, IRQEN_RSE | IRQEN_RTE | IRQEN_ROE);
control_rx_enable(dev, p->enable);
next reply other threads:[~2009-12-18 22:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-18 22:21 Stefani Seibold [this message]
2009-12-18 23:43 ` [patch] media video cx23888 driver: fix possible races using new kfifo_API kfifo_reset() Andy Walls
2009-12-19 10:15 ` Mauro Carvalho Chehab
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1261174870.13019.24.camel@wall-e \
--to=stefani@seibold.net \
--cc=akpm@linux-foundation.org \
--cc=awalls@radix.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.