mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ubi: fastmap: Remove 'ubi' parameter of 'destroy_ai()'
@ 2012-06-28 13:52 Shmulik Ladkani
  2012-06-28 14:45 ` [PATCH] ubi: fastmap: Do not free 'ai' in 'scan_all()' Shmulik Ladkani
  2012-06-29 11:20 ` [PATCH] ubi: fastmap: Remove 'ubi' parameter of 'destroy_ai()' Richard Weinberger
  0 siblings, 2 replies; 4+ messages in thread
From: Shmulik Ladkani @ 2012-06-28 13:52 UTC (permalink / raw)
  To: Richard Weinberger
  Cc: Artem Bityutskiy, linux-kernel, Adrian Hunter, Heinz.Egger,
	thomas.wucher, tglx, tim.bird, Marius.Mazarel, nyoushchenko,
	linux-mtd

From: Shmulik Ladkani <shmulik.ladkani@gmail.com>

The 'ubi' argument of 'destroy_ai' was added during fastmap development,
but it is no longer used.

Signed-off-by: Shmulik Ladkani <shmulik.ladkani@gmail.com>
---
Applies to linux-ubi.git fastmap

diff --git a/drivers/mtd/ubi/attach.c b/drivers/mtd/ubi/attach.c
index 3d9be42..019fbd3 100644
--- a/drivers/mtd/ubi/attach.c
+++ b/drivers/mtd/ubi/attach.c
@@ -97,7 +97,7 @@
  * it that way, or re-structure all the code. :-)
  */
 static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai);
-static void destroy_ai(struct ubi_device *ubi, struct ubi_attach_info *ai);
+static void destroy_ai(struct ubi_attach_info *ai);
 
 /* Temporary variables used during scanning */
 static struct ubi_ec_hdr *ech;
@@ -1219,7 +1219,7 @@ out_vidh:
 out_ech:
 	kfree(ech);
 out_ai:
-	destroy_ai(ubi, ai);
+	destroy_ai(ai);
 	return err;
 }
 
@@ -1280,7 +1280,7 @@ int ubi_attach(struct ubi_device *ubi, int force_scan)
 		 */
 		err = ubi_scan_fastmap(ubi, ai);
 		if (err > 0) {
-			destroy_ai(ubi, ai);
+			destroy_ai(ai);
 			ai = alloc_ai();
 			if (!ai)
 				return -ENOMEM;
@@ -1334,10 +1334,10 @@ int ubi_attach(struct ubi_device *ubi, int force_scan)
 		}
 
 		self_check_eba(ubi, ai, scan_ai);
-		destroy_ai(ubi, scan_ai);
+		destroy_ai(scan_ai);
 	}
 
-	destroy_ai(ubi, ai);
+	destroy_ai(ai);
 	return 0;
 
 out_wl:
@@ -1346,7 +1346,7 @@ out_vtbl:
 	ubi_free_internal_volumes(ubi);
 	vfree(ubi->vtbl);
 out_ai:
-	destroy_ai(ubi, ai);
+	destroy_ai(ai);
 	return err;
 }
 
@@ -1385,10 +1385,9 @@ static void destroy_av(struct ubi_attach_info *ai, struct ubi_ainf_volume *av)
 
 /**
  * destroy_ai - destroy attaching information.
- * @ubi: UBI device object
  * @ai: attaching information
  */
-static void destroy_ai(struct ubi_device *ubi, struct ubi_attach_info *ai)
+static void destroy_ai(struct ubi_attach_info *ai)
 {
 	struct ubi_ainf_peb *aeb, *aeb_tmp;
 	struct ubi_ainf_volume *av;

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

* [PATCH] ubi: fastmap: Do not free 'ai' in 'scan_all()'
  2012-06-28 13:52 [PATCH] ubi: fastmap: Remove 'ubi' parameter of 'destroy_ai()' Shmulik Ladkani
@ 2012-06-28 14:45 ` Shmulik Ladkani
  2012-06-29 11:20   ` Richard Weinberger
  2012-06-29 11:20 ` [PATCH] ubi: fastmap: Remove 'ubi' parameter of 'destroy_ai()' Richard Weinberger
  1 sibling, 1 reply; 4+ messages in thread
From: Shmulik Ladkani @ 2012-06-28 14:45 UTC (permalink / raw)
  To: Richard Weinberger
  Cc: Artem Bityutskiy, linux-kernel, Adrian Hunter, Heinz.Egger,
	thomas.wucher, tglx, tim.bird, Marius.Mazarel, nyoushchenko,
	linux-mtd

From: Shmulik Ladkani <shmulik.ladkani@gmail.com>

Do not call 'destroy_ai(ai)' at error handling of 'scan_all', since:
- 'ai' is allocated in 'ubi_attach' (the caller of scan_all) and
  provided as an argument. It's not scan_all's responsibility to free it
- It is not consistent with scan_all's sister function
  'ubi_attach_fastmap()' which does not free the given 'ai'
- It will cause a double free as 'ubi_attach' (the caller of scan_all)
  already destroys 'ai' in case of an error

Signed-off-by: Shmulik Ladkani <shmulik.ladkani@gmail.com>
---
- compile tested

diff --git a/drivers/mtd/ubi/attach.c b/drivers/mtd/ubi/attach.c
index 019fbd3..8a339e4 100644
--- a/drivers/mtd/ubi/attach.c
+++ b/drivers/mtd/ubi/attach.c
@@ -1152,11 +1152,11 @@ static int scan_all(struct ubi_device *ubi, struct ubi_attach_info *ai)
 					       sizeof(struct ubi_ainf_peb),
 					       0, 0, NULL);
 	if (!ai->aeb_slab_cache)
-		goto out_ai;
+		return -ENOMEM;
 
 	ech = kzalloc(ubi->ec_hdr_alsize, GFP_KERNEL);
 	if (!ech)
-		goto out_ai;
+		return -ENOMEM;
 
 	vidh = ubi_zalloc_vid_hdr(ubi, GFP_KERNEL);
 	if (!vidh)
@@ -1218,8 +1218,6 @@ out_vidh:
 	ubi_free_vid_hdr(ubi, vidh);
 out_ech:
 	kfree(ech);
-out_ai:
-	destroy_ai(ai);
 	return err;
 }
 

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

* Re: [PATCH] ubi: fastmap: Remove 'ubi' parameter of 'destroy_ai()'
  2012-06-28 13:52 [PATCH] ubi: fastmap: Remove 'ubi' parameter of 'destroy_ai()' Shmulik Ladkani
  2012-06-28 14:45 ` [PATCH] ubi: fastmap: Do not free 'ai' in 'scan_all()' Shmulik Ladkani
@ 2012-06-29 11:20 ` Richard Weinberger
  1 sibling, 0 replies; 4+ messages in thread
From: Richard Weinberger @ 2012-06-29 11:20 UTC (permalink / raw)
  To: Shmulik Ladkani
  Cc: Artem Bityutskiy, linux-kernel, Adrian Hunter, Heinz.Egger,
	thomas.wucher, tglx, tim.bird, Marius.Mazarel, nyoushchenko,
	linux-mtd

Am Thu, 28 Jun 2012 16:52:39 +0300
schrieb Shmulik Ladkani <shmulik.ladkani@gmail.com>:

> From: Shmulik Ladkani <shmulik.ladkani@gmail.com>
> 
> The 'ubi' argument of 'destroy_ai' was added during fastmap
> development, but it is no longer used.
> 
> Signed-off-by: Shmulik Ladkani <shmulik.ladkani@gmail.com>
> ---

Applied!

Thanks,
//richard

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

* Re: [PATCH] ubi: fastmap: Do not free 'ai' in 'scan_all()'
  2012-06-28 14:45 ` [PATCH] ubi: fastmap: Do not free 'ai' in 'scan_all()' Shmulik Ladkani
@ 2012-06-29 11:20   ` Richard Weinberger
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Weinberger @ 2012-06-29 11:20 UTC (permalink / raw)
  To: Shmulik Ladkani
  Cc: Artem Bityutskiy, linux-kernel, Adrian Hunter, Heinz.Egger,
	thomas.wucher, tglx, tim.bird, Marius.Mazarel, nyoushchenko,
	linux-mtd

Am Thu, 28 Jun 2012 17:45:46 +0300
schrieb Shmulik Ladkani <shmulik.ladkani@gmail.com>:

> From: Shmulik Ladkani <shmulik.ladkani@gmail.com>
> 
> Do not call 'destroy_ai(ai)' at error handling of 'scan_all', since:
> - 'ai' is allocated in 'ubi_attach' (the caller of scan_all) and
>   provided as an argument. It's not scan_all's responsibility to free
> it
> - It is not consistent with scan_all's sister function
>   'ubi_attach_fastmap()' which does not free the given 'ai'
> - It will cause a double free as 'ubi_attach' (the caller of scan_all)
>   already destroys 'ai' in case of an error
> 
> Signed-off-by: Shmulik Ladkani <shmulik.ladkani@gmail.com>
> ---

Applied!

Thanks,
//richard

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

end of thread, other threads:[~2012-06-29 11:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-28 13:52 [PATCH] ubi: fastmap: Remove 'ubi' parameter of 'destroy_ai()' Shmulik Ladkani
2012-06-28 14:45 ` [PATCH] ubi: fastmap: Do not free 'ai' in 'scan_all()' Shmulik Ladkani
2012-06-29 11:20   ` Richard Weinberger
2012-06-29 11:20 ` [PATCH] ubi: fastmap: Remove 'ubi' parameter of 'destroy_ai()' Richard Weinberger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®