[Yaffs] [PATCH] Free dev->tn_swap_buffer upon deinitializati…

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Michał Kępień
Date:  
To: yaffs
Subject: [Yaffs] [PATCH] Free dev->tn_swap_buffer upon deinitialization
yaffs_endian_config() allocates a buffer (dev->tn_swap_buffer) for the
purpose of converting tnodes between little-endian and big-endian byte
orders when necessary. This buffer is never released. Add a new
function, yaffs_endian_deinit(), which is a cleanup counterpart of
yaffs_endian_config(). Call the new function upon deinitialization so
that dev->tn_swap_buffer gets released.

Signed-off-by: Michał Kępień <>
---
yaffs_endian.c | 5 +++++
yaffs_endian.h | 1 +
yaffs_guts.c | 1 +
3 files changed, 7 insertions(+)

diff --git a/yaffs_endian.c b/yaffs_endian.c
index 6103f4e..2870d6c 100644
--- a/yaffs_endian.c
+++ b/yaffs_endian.c
@@ -103,3 +103,8 @@ void yaffs_endian_config(struct yaffs_dev *dev)
     if (dev->swap_endian)
         dev->tn_swap_buffer = kmalloc(dev->tnode_size, GFP_NOFS);
 }
+
+void yaffs_endian_deinit(struct yaffs_dev *dev) {
+    if (dev->swap_endian)
+        kfree(dev->tn_swap_buffer);
+}
diff --git a/yaffs_endian.h b/yaffs_endian.h
index 8c27189..068f10d 100644
--- a/yaffs_endian.h
+++ b/yaffs_endian.h
@@ -50,5 +50,6 @@ void yaffs_do_endian_oh(struct yaffs_dev *dev, struct yaffs_obj_hdr *oh);
 void yaffs_do_endian_packed_tags2(struct yaffs_dev *dev,
                 struct yaffs_packed_tags2_tags_only *ptt);
 void yaffs_endian_config(struct yaffs_dev *dev);
+void yaffs_endian_deinit(struct yaffs_dev *dev);


 #endif
diff --git a/yaffs_guts.c b/yaffs_guts.c
index 3e33916..6fba922 100644
--- a/yaffs_guts.c
+++ b/yaffs_guts.c
@@ -4814,6 +4814,7 @@ void yaffs_deinitialise(struct yaffs_dev *dev)
         yaffs_deinit_tnodes_and_objs(dev);
         yaffs_summary_deinit(dev);
         yaffs_cache_deinit(dev);
+        yaffs_endian_deinit(dev);


         kfree(dev->gc_cleanup_list);


--
2.33.0