* [patch] mtd: nand: sunxi: prevent a small memory leak
@ 2016-06-24 12:24 ` Dan Carpenter
0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2016-06-24 12:24 UTC (permalink / raw)
To: Boris Brezillon
Cc: Richard Weinberger, David Woodhouse, Brian Norris, Maxime Ripard,
Chen-Yu Tsai, linux-mtd, kernel-janitors
I moved the sanity check on ecc->size before the allocation so that we
don't leak memory on error.
Fixes: 05af074a4b73 ('mtd: nand: sunxi: check ecc->size values')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/drivers/mtd/nand/sunxi_nand.c b/drivers/mtd/nand/sunxi_nand.c
index f582fe4..9f4e1c7 100644
--- a/drivers/mtd/nand/sunxi_nand.c
+++ b/drivers/mtd/nand/sunxi_nand.c
@@ -1812,13 +1812,13 @@ static int sunxi_nand_hw_common_ecc_ctrl_init(struct mtd_info *mtd,
int ret;
int i;
+ if (ecc->size != 512 && ecc->size != 1024)
+ return -EINVAL;
+
data = kzalloc(sizeof(*data), GFP_KERNEL);
if (!data)
return -ENOMEM;
- if (ecc->size != 512 && ecc->size != 1024)
- return -EINVAL;
-
/* Prefer 1k ECC chunk over 512 ones */
if (ecc->size = 512 && mtd->writesize > 512) {
ecc->size = 1024;
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [patch] mtd: nand: sunxi: prevent a small memory leak
@ 2016-06-24 12:24 ` Dan Carpenter
0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2016-06-24 12:24 UTC (permalink / raw)
To: Boris Brezillon
Cc: Richard Weinberger, David Woodhouse, Brian Norris, Maxime Ripard,
Chen-Yu Tsai, linux-mtd, kernel-janitors
I moved the sanity check on ecc->size before the allocation so that we
don't leak memory on error.
Fixes: 05af074a4b73 ('mtd: nand: sunxi: check ecc->size values')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/drivers/mtd/nand/sunxi_nand.c b/drivers/mtd/nand/sunxi_nand.c
index f582fe4..9f4e1c7 100644
--- a/drivers/mtd/nand/sunxi_nand.c
+++ b/drivers/mtd/nand/sunxi_nand.c
@@ -1812,13 +1812,13 @@ static int sunxi_nand_hw_common_ecc_ctrl_init(struct mtd_info *mtd,
int ret;
int i;
+ if (ecc->size != 512 && ecc->size != 1024)
+ return -EINVAL;
+
data = kzalloc(sizeof(*data), GFP_KERNEL);
if (!data)
return -ENOMEM;
- if (ecc->size != 512 && ecc->size != 1024)
- return -EINVAL;
-
/* Prefer 1k ECC chunk over 512 ones */
if (ecc->size == 512 && mtd->writesize > 512) {
ecc->size = 1024;
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [patch] mtd: nand: sunxi: prevent a small memory leak
2016-06-24 12:24 ` Dan Carpenter
@ 2016-07-04 12:42 ` Boris Brezillon
-1 siblings, 0 replies; 4+ messages in thread
From: Boris Brezillon @ 2016-07-04 12:42 UTC (permalink / raw)
To: Dan Carpenter
Cc: Richard Weinberger, David Woodhouse, Brian Norris, Maxime Ripard,
Chen-Yu Tsai, linux-mtd, kernel-janitors
On Fri, 24 Jun 2016 15:24:03 +0300
Dan Carpenter <dan.carpenter@oracle.com> wrote:
> I moved the sanity check on ecc->size before the allocation so that we
> don't leak memory on error.
>
> Fixes: 05af074a4b73 ('mtd: nand: sunxi: check ecc->size values')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Applied.
Thanks,
Boris
>
> diff --git a/drivers/mtd/nand/sunxi_nand.c b/drivers/mtd/nand/sunxi_nand.c
> index f582fe4..9f4e1c7 100644
> --- a/drivers/mtd/nand/sunxi_nand.c
> +++ b/drivers/mtd/nand/sunxi_nand.c
> @@ -1812,13 +1812,13 @@ static int sunxi_nand_hw_common_ecc_ctrl_init(struct mtd_info *mtd,
> int ret;
> int i;
>
> + if (ecc->size != 512 && ecc->size != 1024)
> + return -EINVAL;
> +
> data = kzalloc(sizeof(*data), GFP_KERNEL);
> if (!data)
> return -ENOMEM;
>
> - if (ecc->size != 512 && ecc->size != 1024)
> - return -EINVAL;
> -
> /* Prefer 1k ECC chunk over 512 ones */
> if (ecc->size = 512 && mtd->writesize > 512) {
> ecc->size = 1024;
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch] mtd: nand: sunxi: prevent a small memory leak
@ 2016-07-04 12:42 ` Boris Brezillon
0 siblings, 0 replies; 4+ messages in thread
From: Boris Brezillon @ 2016-07-04 12:42 UTC (permalink / raw)
To: Dan Carpenter
Cc: Richard Weinberger, David Woodhouse, Brian Norris, Maxime Ripard,
Chen-Yu Tsai, linux-mtd, kernel-janitors
On Fri, 24 Jun 2016 15:24:03 +0300
Dan Carpenter <dan.carpenter@oracle.com> wrote:
> I moved the sanity check on ecc->size before the allocation so that we
> don't leak memory on error.
>
> Fixes: 05af074a4b73 ('mtd: nand: sunxi: check ecc->size values')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Applied.
Thanks,
Boris
>
> diff --git a/drivers/mtd/nand/sunxi_nand.c b/drivers/mtd/nand/sunxi_nand.c
> index f582fe4..9f4e1c7 100644
> --- a/drivers/mtd/nand/sunxi_nand.c
> +++ b/drivers/mtd/nand/sunxi_nand.c
> @@ -1812,13 +1812,13 @@ static int sunxi_nand_hw_common_ecc_ctrl_init(struct mtd_info *mtd,
> int ret;
> int i;
>
> + if (ecc->size != 512 && ecc->size != 1024)
> + return -EINVAL;
> +
> data = kzalloc(sizeof(*data), GFP_KERNEL);
> if (!data)
> return -ENOMEM;
>
> - if (ecc->size != 512 && ecc->size != 1024)
> - return -EINVAL;
> -
> /* Prefer 1k ECC chunk over 512 ones */
> if (ecc->size == 512 && mtd->writesize > 512) {
> ecc->size = 1024;
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-07-04 12:42 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-24 12:24 [patch] mtd: nand: sunxi: prevent a small memory leak Dan Carpenter
2016-06-24 12:24 ` Dan Carpenter
2016-07-04 12:42 ` Boris Brezillon
2016-07-04 12:42 ` Boris Brezillon
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.