linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mtdoops: fix the oops_page_used array size
@ 2011-11-29 10:49 Roman Tereshonkov
  2011-12-04 13:44 ` Artem Bityutskiy
  0 siblings, 1 reply; 4+ messages in thread
From: Roman Tereshonkov @ 2011-11-29 10:49 UTC (permalink / raw)
  To: linux-mtd; +Cc: rpurdie, dwmw2, Roman Tereshonkov

The array of unsigned long pointed by oops_page_used is allocated
by vmalloc which requires the size to be in bytes.

Signed-off-by: Roman Tereshonkov <roman.tereshonkov@nokia.com>
---
 drivers/mtd/mtdoops.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/mtd/mtdoops.c b/drivers/mtd/mtdoops.c
index 1e2fa62..0782b31 100644
--- a/drivers/mtd/mtdoops.c
+++ b/drivers/mtd/mtdoops.c
@@ -369,7 +369,7 @@ static void mtdoops_notify_add(struct mtd_info *mtd)
 
 	/* oops_page_used is a bit field */
 	cxt->oops_page_used = vmalloc(DIV_ROUND_UP(mtdoops_pages,
-			BITS_PER_LONG));
+			BITS_PER_LONG) * sizeof(unsigned long));
 	if (!cxt->oops_page_used) {
 		printk(KERN_ERR "mtdoops: could not allocate page array\n");
 		return;
-- 
1.7.0.4

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

* Re: [PATCH] mtdoops: fix the oops_page_used array size
  2011-11-29 10:49 [PATCH] mtdoops: fix the oops_page_used array size Roman Tereshonkov
@ 2011-12-04 13:44 ` Artem Bityutskiy
  2011-12-07 15:25   ` Roman Tereshonkov
  0 siblings, 1 reply; 4+ messages in thread
From: Artem Bityutskiy @ 2011-12-04 13:44 UTC (permalink / raw)
  To: Roman Tereshonkov; +Cc: dwmw2, rpurdie, linux-mtd

[-- Attachment #1: Type: text/plain, Size: 919 bytes --]

On Tue, 2011-11-29 at 12:49 +0200, Roman Tereshonkov wrote:
> The array of unsigned long pointed by oops_page_used is allocated
> by vmalloc which requires the size to be in bytes.
> 
> Signed-off-by: Roman Tereshonkov <roman.tereshonkov@nokia.com>
> ---
>  drivers/mtd/mtdoops.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/mtd/mtdoops.c b/drivers/mtd/mtdoops.c
> index 1e2fa62..0782b31 100644
> --- a/drivers/mtd/mtdoops.c
> +++ b/drivers/mtd/mtdoops.c
> @@ -369,7 +369,7 @@ static void mtdoops_notify_add(struct mtd_info *mtd)
>  
>  	/* oops_page_used is a bit field */
>  	cxt->oops_page_used = vmalloc(DIV_ROUND_UP(mtdoops_pages,
> -			BITS_PER_LONG));
> +			BITS_PER_LONG) * sizeof(unsigned long));

But it is already in bytes. I do not understand which problem this patch
fixes - it looks incorrect to me.

-- 
Best Regards,
Artem Bityutskiy

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [PATCH] mtdoops: fix the oops_page_used array size
  2011-12-04 13:44 ` Artem Bityutskiy
@ 2011-12-07 15:25   ` Roman Tereshonkov
  2011-12-08 21:58     ` Artem Bityutskiy
  0 siblings, 1 reply; 4+ messages in thread
From: Roman Tereshonkov @ 2011-12-07 15:25 UTC (permalink / raw)
  To: Artem Bityutskiy; +Cc: linux-mtd

On Sun, Dec 04, 2011 at 03:44:57PM +0200, Artem Bityutskiy wrote:
> On Tue, 2011-11-29 at 12:49 +0200, Roman Tereshonkov wrote:
> > The array of unsigned long pointed by oops_page_used is allocated
> > by vmalloc which requires the size to be in bytes.
> > 
> > Signed-off-by: Roman Tereshonkov <roman.tereshonkov at nokia.com>
> > ---
> >  drivers/mtd/mtdoops.c |    2 +-
> >  1 files changed, 1 insertions(+), 1 deletions(-)
> > 
> > diff --git a/drivers/mtd/mtdoops.c b/drivers/mtd/mtdoops.c
> > index 1e2fa62..0782b31 100644
> > --- a/drivers/mtd/mtdoops.c
> > +++ b/drivers/mtd/mtdoops.c
> > @@ -369,7 +369,7 @@ static void mtdoops_notify_add(struct mtd_info *mtd)
> >  
> >  	/* oops_page_used is a bit field */
> >  	cxt->oops_page_used = vmalloc(DIV_ROUND_UP(mtdoops_pages,
> > -			BITS_PER_LONG));
> > +			BITS_PER_LONG) * sizeof(unsigned long));
> 
> But it is already in bytes. I do not understand which problem this patch
> fixes - it looks incorrect to me.

BITS_PER_LONG is equal to 32.
If we want to allocate memory for 32 pages with one bit per page then
32 / BITS_PER_LONG  is equal to 1 byte that is 8 bits.
To fix it we need to multiply the result by sizeof(unsigned long) equal to 4.



Regards
Roman Tereshonkov
> 
> -- 
> Best Regards,
> Artem Bityutskiy
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: signature.asc
> Type: application/pgp-signature
> Size: 836 bytes
> Desc: This is a digitally signed message part
> URL: <http://lists.infradead.org/pipermail/linux-mtd/attachments/20111204/a96b926e/attachment.sig>

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

* Re: [PATCH] mtdoops: fix the oops_page_used array size
  2011-12-07 15:25   ` Roman Tereshonkov
@ 2011-12-08 21:58     ` Artem Bityutskiy
  0 siblings, 0 replies; 4+ messages in thread
From: Artem Bityutskiy @ 2011-12-08 21:58 UTC (permalink / raw)
  To: Roman Tereshonkov; +Cc: linux-mtd

On Wed, 2011-12-07 at 17:25 +0200, Roman Tereshonkov wrote:
> BITS_PER_LONG is equal to 32.
> If we want to allocate memory for 32 pages with one bit per page then
> 32 / BITS_PER_LONG  is equal to 1 byte that is 8 bits.
> To fix it we need to multiply the result by sizeof(unsigned long)
> equal to 4.

Ah, you are right. This should also go to the stable tree, I've
added Cc: stable@kernel.org

Pushed to l2-mtd-2.6.git thanks.

Artem.

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

end of thread, other threads:[~2011-12-08 21:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-29 10:49 [PATCH] mtdoops: fix the oops_page_used array size Roman Tereshonkov
2011-12-04 13:44 ` Artem Bityutskiy
2011-12-07 15:25   ` Roman Tereshonkov
2011-12-08 21:58     ` Artem Bityutskiy

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