[PATCH] mtd: mtd_torturetest can cause stack overflows

Huang Shijie b32955 at freescale.com
Mon Feb 4 21:05:14 EST 2013


于 2013年02月05日 05:29, Al Cooper 写道:
> diff --git a/drivers/mtd/tests/mtd_torturetest.c b/drivers/mtd/tests/mtd_torturetest.c
> index c4cde1e..a777cc8 100644
> --- a/drivers/mtd/tests/mtd_torturetest.c
> +++ b/drivers/mtd/tests/mtd_torturetest.c
> @@ -208,7 +208,7 @@ static inline int write_pattern(int ebnum, void *buf)
>   static int __init tort_init(void)
>   {
>   	int err = 0, i, infinite = !cycles_count;
> -	int bad_ebs[ebcnt];
> +	int *bad_ebs;
>
>   	printk(KERN_INFO "\n");
>   	printk(KERN_INFO "=================================================\n");
> @@ -273,6 +273,12 @@ static int __init tort_init(void)
>   		goto out_patt_FF;
>   	}
>
> +	bad_ebs = kmalloc(sizeof(*bad_ebs) * ebcnt, GFP_KERNEL);
I think it's better to use the kcalloc() here.

thanks
Huang Shijie




More information about the linux-mtd mailing list