linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tmio_mmc: fix misuse of kunmap_atomic() in tmio_mmc.c
@ 2010-08-12 15:51 Eric Miao
  2010-08-14 20:33 ` Guennadi Liakhovetski
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Miao @ 2010-08-12 15:51 UTC (permalink / raw)
  To: linux-arm-kernel

According to commit 597781f3e51f48ef8e67be772196d9e9673752c4

    kmap_atomic: make kunmap_atomic() harder to misuse

kunmap_atomic() takes a pointer to within the page, instead of a pointer
to 'struct page'.  So tmio_mmc_kunmap_atomic() should really take the
pointer what tmio_mmc_kmap_atomic() returns.

Cc: Ian Molton <spyro@f2s.com>
Cc: Magnus Damm <damm@opensource.se>
Signed-off-by: Eric Miao <eric.y.miao@gmail.com>
---
 drivers/mmc/host/tmio_mmc.c |    2 +-
 drivers/mmc/host/tmio_mmc.h |    5 ++---
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/mmc/host/tmio_mmc.c b/drivers/mmc/host/tmio_mmc.c
index ee7d0a5..24b9c3e 100644
--- a/drivers/mmc/host/tmio_mmc.c
+++ b/drivers/mmc/host/tmio_mmc.c
@@ -191,7 +191,7 @@ static void tmio_mmc_pio_irq(struct tmio_mmc_host *host)
 
 	host->sg_off += count;
 
-	tmio_mmc_kunmap_atomic(host, &flags);
+	tmio_mmc_kunmap_atomic(buf, &flags);
 
 	if (host->sg_off == host->sg_ptr->length)
 		tmio_mmc_next_sg(host);
diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h
index 64f7d5d..8f308b9 100644
--- a/drivers/mmc/host/tmio_mmc.h
+++ b/drivers/mmc/host/tmio_mmc.h
@@ -186,10 +186,9 @@ static inline char *tmio_mmc_kmap_atomic(struct tmio_mmc_host *host,
 	return kmap_atomic(sg_page(sg), KM_BIO_SRC_IRQ) + sg->offset;
 }
 
-static inline void tmio_mmc_kunmap_atomic(struct tmio_mmc_host *host,
-	unsigned long *flags)
+static inline void tmio_mmc_kunmap_atomic(void *buf, unsigned long *flags)
 {
-	kunmap_atomic(sg_page(host->sg_ptr), KM_BIO_SRC_IRQ);
+	kunmap_atomic(buf, KM_BIO_SRC_IRQ);
 	local_irq_restore(*flags);
 }
 
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH] tmio_mmc: fix misuse of kunmap_atomic() in tmio_mmc.c
  2010-08-12 15:51 [PATCH] tmio_mmc: fix misuse of kunmap_atomic() in tmio_mmc.c Eric Miao
@ 2010-08-14 20:33 ` Guennadi Liakhovetski
  2010-08-15  1:53   ` Eric Miao
  0 siblings, 1 reply; 3+ messages in thread
From: Guennadi Liakhovetski @ 2010-08-14 20:33 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Eric

On Thu, 12 Aug 2010, Eric Miao wrote:

> According to commit 597781f3e51f48ef8e67be772196d9e9673752c4
> 
>     kmap_atomic: make kunmap_atomic() harder to misuse
> 
> kunmap_atomic() takes a pointer to within the page, instead of a pointer
> to 'struct page'.  So tmio_mmc_kunmap_atomic() should really take the
> pointer what tmio_mmc_kmap_atomic() returns.

As you have seen, I've also prepared a fix for this problem, just haven't 
sent it fast enough;) And, I think, your fix isn't quite correct: "buf" is 
not the returned value from tmio_mmc_kmap_atomic(), so, you cannot use it 
for unmapping.

Thanks
Guennadi

> 
> Cc: Ian Molton <spyro@f2s.com>
> Cc: Magnus Damm <damm@opensource.se>
> Signed-off-by: Eric Miao <eric.y.miao@gmail.com>
> ---
>  drivers/mmc/host/tmio_mmc.c |    2 +-
>  drivers/mmc/host/tmio_mmc.h |    5 ++---
>  2 files changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/mmc/host/tmio_mmc.c b/drivers/mmc/host/tmio_mmc.c
> index ee7d0a5..24b9c3e 100644
> --- a/drivers/mmc/host/tmio_mmc.c
> +++ b/drivers/mmc/host/tmio_mmc.c
> @@ -191,7 +191,7 @@ static void tmio_mmc_pio_irq(struct tmio_mmc_host *host)
>  
>  	host->sg_off += count;
>  
> -	tmio_mmc_kunmap_atomic(host, &flags);
> +	tmio_mmc_kunmap_atomic(buf, &flags);
>  
>  	if (host->sg_off == host->sg_ptr->length)
>  		tmio_mmc_next_sg(host);
> diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h
> index 64f7d5d..8f308b9 100644
> --- a/drivers/mmc/host/tmio_mmc.h
> +++ b/drivers/mmc/host/tmio_mmc.h
> @@ -186,10 +186,9 @@ static inline char *tmio_mmc_kmap_atomic(struct tmio_mmc_host *host,
>  	return kmap_atomic(sg_page(sg), KM_BIO_SRC_IRQ) + sg->offset;
>  }
>  
> -static inline void tmio_mmc_kunmap_atomic(struct tmio_mmc_host *host,
> -	unsigned long *flags)
> +static inline void tmio_mmc_kunmap_atomic(void *buf, unsigned long *flags)
>  {
> -	kunmap_atomic(sg_page(host->sg_ptr), KM_BIO_SRC_IRQ);
> +	kunmap_atomic(buf, KM_BIO_SRC_IRQ);
>  	local_irq_restore(*flags);
>  }
>  
> -- 
> 1.7.0.4
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> 

---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] tmio_mmc: fix misuse of kunmap_atomic() in tmio_mmc.c
  2010-08-14 20:33 ` Guennadi Liakhovetski
@ 2010-08-15  1:53   ` Eric Miao
  0 siblings, 0 replies; 3+ messages in thread
From: Eric Miao @ 2010-08-15  1:53 UTC (permalink / raw)
  To: linux-arm-kernel

On Sun, Aug 15, 2010 at 4:33 AM, Guennadi Liakhovetski
<g.liakhovetski@gmx.de> wrote:
> Hi Eric
>
> On Thu, 12 Aug 2010, Eric Miao wrote:
>
>> According to commit 597781f3e51f48ef8e67be772196d9e9673752c4
>>
>> ? ? kmap_atomic: make kunmap_atomic() harder to misuse
>>
>> kunmap_atomic() takes a pointer to within the page, instead of a pointer
>> to 'struct page'. ?So tmio_mmc_kunmap_atomic() should really take the
>> pointer what tmio_mmc_kmap_atomic() returns.
>
> As you have seen, I've also prepared a fix for this problem, just haven't
> sent it fast enough;) And, I think, your fix isn't quite correct: "buf" is
> not the returned value from tmio_mmc_kmap_atomic(), so, you cannot use it
> for unmapping.
>

Nah, just trying to fix my build here, didn't look into that too much.
Your patch is of course welcome ;-)

> Thanks
> Guennadi
>
>>
>> Cc: Ian Molton <spyro@f2s.com>
>> Cc: Magnus Damm <damm@opensource.se>
>> Signed-off-by: Eric Miao <eric.y.miao@gmail.com>
>> ---
>> ?drivers/mmc/host/tmio_mmc.c | ? ?2 +-
>> ?drivers/mmc/host/tmio_mmc.h | ? ?5 ++---
>> ?2 files changed, 3 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/mmc/host/tmio_mmc.c b/drivers/mmc/host/tmio_mmc.c
>> index ee7d0a5..24b9c3e 100644
>> --- a/drivers/mmc/host/tmio_mmc.c
>> +++ b/drivers/mmc/host/tmio_mmc.c
>> @@ -191,7 +191,7 @@ static void tmio_mmc_pio_irq(struct tmio_mmc_host *host)
>>
>> ? ? ? host->sg_off += count;
>>
>> - ? ? tmio_mmc_kunmap_atomic(host, &flags);
>> + ? ? tmio_mmc_kunmap_atomic(buf, &flags);
>>
>> ? ? ? if (host->sg_off == host->sg_ptr->length)
>> ? ? ? ? ? ? ? tmio_mmc_next_sg(host);
>> diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h
>> index 64f7d5d..8f308b9 100644
>> --- a/drivers/mmc/host/tmio_mmc.h
>> +++ b/drivers/mmc/host/tmio_mmc.h
>> @@ -186,10 +186,9 @@ static inline char *tmio_mmc_kmap_atomic(struct tmio_mmc_host *host,
>> ? ? ? return kmap_atomic(sg_page(sg), KM_BIO_SRC_IRQ) + sg->offset;
>> ?}
>>
>> -static inline void tmio_mmc_kunmap_atomic(struct tmio_mmc_host *host,
>> - ? ? unsigned long *flags)
>> +static inline void tmio_mmc_kunmap_atomic(void *buf, unsigned long *flags)
>> ?{
>> - ? ? kunmap_atomic(sg_page(host->sg_ptr), KM_BIO_SRC_IRQ);
>> + ? ? kunmap_atomic(buf, KM_BIO_SRC_IRQ);
>> ? ? ? local_irq_restore(*flags);
>> ?}
>>
>> --
>> 1.7.0.4
>>
>>
>> _______________________________________________
>> linux-arm-kernel mailing list
>> linux-arm-kernel at lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>>
>
> ---
> Guennadi Liakhovetski, Ph.D.
> Freelance Open-Source Software Developer
> http://www.open-technology.de/
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-08-15  1:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-12 15:51 [PATCH] tmio_mmc: fix misuse of kunmap_atomic() in tmio_mmc.c Eric Miao
2010-08-14 20:33 ` Guennadi Liakhovetski
2010-08-15  1:53   ` Eric Miao

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).