LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@infradead.org>
To: LKML <linux-kernel@vger.kernel.org>
Cc: V4L-DVB Maintainers <v4l-dvb-maintainer@linuxtv.org>,
	Mauro Carvalho Chehab <mchehab@infradead.org>
Subject: [PATCH 2/9] V4L/DVB (5020): Fix: disable interrupts while at KM_BOUNCE_READ
Date: Mon, 15 Jan 2007 16:37:05 -0200	[thread overview]
Message-ID: <20070115183705.PS5598290002@infradead.org> (raw)
In-Reply-To: <20070115183647.PS0588920000@infradead.org>


From: Mauro Carvalho Chehab <mchehab@infradead.org>

vivi.c uses the KM_BOUNCE_READ with local interrupts enabled. 
This means that if a disk interrupt occurs while vivi.c is using this
fixmap slot, the vivi.c driver will, upon return from that interrupt, find
that the fixmap slot now points at a different physical page.
The net result will probably be rare corruption of disk file contents,
because viv.c will now be altering the page which the disk code was
recently using. 

Thanks to Andrew Morton for pointing this.
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
---

 drivers/media/video/vivi.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c
index bacb311..d4cf556 100644
--- a/drivers/media/video/vivi.c
+++ b/drivers/media/video/vivi.c
@@ -270,10 +270,15 @@ static void gen_line(struct sg_to_addr t
 	char *p,*s,*basep;
 	struct page *pg;
 	u8   chr,r,g,b,color;
+	unsigned long flags;
+	spinlock_t spinlock;
+
+	spin_lock_init(&spinlock);
 
 	/* Get first addr pointed to pixel position */
 	oldpg=get_addr_pos(pos,pages,to_addr);
 	pg=pfn_to_page(sg_dma_address(to_addr[oldpg].sg) >> PAGE_SHIFT);
+	spin_lock_irqsave(&spinlock,flags);
 	basep = kmap_atomic(pg, KM_BOUNCE_READ)+to_addr[oldpg].sg->offset;
 
 	/* We will just duplicate the second pixel at the packet */
@@ -376,6 +381,8 @@ static void gen_line(struct sg_to_addr t
 
 end:
 	kunmap_atomic(basep, KM_BOUNCE_READ);
+	spin_unlock_irqrestore(&spinlock,flags);
+
 }
 static void vivi_fillbuff(struct vivi_dev *dev,struct vivi_buffer *buf)
 {


  parent reply	other threads:[~2007-01-15 19:13 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-15 18:36 [PATCH 0/9] V4L/DVB updates Mauro Carvalho Chehab
2007-01-15 18:37 ` [PATCH 3/9] V4L/DVB (5021): Cx88xx: Fix lockup on suspend Mauro Carvalho Chehab
2007-01-15 18:37 ` Mauro Carvalho Chehab [this message]
2007-01-15 18:37 ` [PATCH 1/9] V4L/DVB (5019): Fix the frame->grabstate update in read() entry point Mauro Carvalho Chehab
2007-01-15 18:37 ` [PATCH 7/9] V4L/DVB (5069): Fix bttv and friends on 64bit machines with lots of memory Mauro Carvalho Chehab
2007-01-15 18:37 ` [PATCH 5/9] V4L/DVB (5029): Ks0127 status flags Mauro Carvalho Chehab
2007-01-15 18:37 ` [PATCH 6/9] V4L/DVB (5033): MSI TV@nywhere Plus fixes Mauro Carvalho Chehab
2007-01-15 18:37 ` [PATCH 4/9] V4L/DVB (5024): Fix quickcam communicator driver for big endian architectures Mauro Carvalho Chehab
2007-01-15 18:37 ` [PATCH 8/9] V4L/DVB (5071): Tveeprom: autodetect LG TAPC G701D as tuner type 37 Mauro Carvalho Chehab
2007-01-15 18:37 ` [PATCH 9/9] V4L/DVB (5023): Fix compilation on ppc32 architecture 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=20070115183705.PS5598290002@infradead.org \
    --to=mchehab@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=v4l-dvb-maintainer@linuxtv.org \
    --subject='Re: [PATCH 2/9] V4L/DVB (5020): Fix: disable interrupts while at KM_BOUNCE_READ' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).