All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@sandeen.net>
To: xfs-oss <xfs@oss.sgi.com>
Subject: [PATCH V2] xfs_repair: fix record_allocation list manipulation
Date: Sat, 19 Sep 2009 09:42:04 -0500	[thread overview]
Message-ID: <4AB4EDBC.9050609@sandeen.net> (raw)
In-Reply-To: <4AB300CC.5020707@sandeen.net>

clang found this one too as a "Dead assignment"

Unless my pointer-fu is totally messed up, this function
was never actually updating the list head.

This would mean that the later free_allocations() calls in
incore_ext_teardown() and free_rt_dup_extent_tree() don't
actually free any items, and therefore leak memory.

V2: now with correct pointer-fu.

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
---

(We could use Jeff's doubly-linked list patch too, though we
really don't need both pointers, and there are still other
singly-linked lists throughout repair...)

clang record:

http://sandeen.net/clang/xfsprogs/2009-09-09-1/report-1Jnl15.html#EndPath

diff --git a/repair/incore.c b/repair/incore.c
index 84626c9..0fd0e89 100644
--- a/repair/incore.c
+++ b/repair/incore.c
@@ -30,10 +30,10 @@
  * if set to NULL if empty.
  */
 void
-record_allocation(ba_rec_t *addr, ba_rec_t *list)
+record_allocation(ba_rec_t *addr, ba_rec_t **list)
 {
-	addr->next = list;
-	list = addr;
+	addr->next = *list;
+	*list = addr;
 
 	return;
 }
diff --git a/repair/incore.h b/repair/incore.h
index 1f0f45a..4f90dd6 100644
--- a/repair/incore.h
+++ b/repair/incore.h
@@ -33,7 +33,7 @@ typedef struct ba_rec  {
 	struct ba_rec	*next;
 } ba_rec_t;
 
-void			record_allocation(ba_rec_t *addr, ba_rec_t *list);
+void			record_allocation(ba_rec_t *addr, ba_rec_t **list);
 void			free_allocations(ba_rec_t *list);
 
 /*
diff --git a/repair/incore_ext.c b/repair/incore_ext.c
index a2acbf4..90d2074 100644
--- a/repair/incore_ext.c
+++ b/repair/incore_ext.c
@@ -120,7 +120,7 @@ mk_extent_tree_nodes(xfs_agblock_t new_startblock,
 			do_error(
 			_("couldn't allocate new extent descriptors.\n"));
 
-		record_allocation(&rec->alloc_rec, ba_list);
+		record_allocation(&rec->alloc_rec, &ba_list);
 
 		new = &rec->extents[0];
 
@@ -678,7 +678,7 @@ mk_rt_extent_tree_nodes(xfs_drtbno_t new_startblock,
 			do_error(
 			_("couldn't allocate new extent descriptors.\n"));
 
-		record_allocation(&rec->alloc_rec, rt_ba_list);
+		record_allocation(&rec->alloc_rec, &rt_ba_list);
 
 		new = &rec->extents[0];
 

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  parent reply	other threads:[~2009-09-19 14:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-18  3:38 [PATCH] xfs_repair: fix record_allocation list manipulation Eric Sandeen
2009-09-18  4:54 ` Eric Sandeen
2009-09-18  5:19   ` [PATCH] repair: replaced custom block allocation linked lists with list_heads Josef 'Jeff' Sipek
2009-09-25 14:41     ` Eric Sandeen
2009-09-19 14:42 ` Eric Sandeen [this message]
2009-09-22 12:02   ` [PATCH V2] xfs_repair: fix record_allocation list manipulation Christoph Hellwig
2009-09-22 15:21     ` Eric Sandeen
2009-09-22 20:04       ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4AB4EDBC.9050609@sandeen.net \
    --to=sandeen@sandeen.net \
    --cc=xfs@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.