btrfs-progs: add malloc check in transaction.h/btrfs_start_transaction
PATCH 1/1 btrfs-progs: add malloc check in transaction.h/btrfs_start_transaction
For malloc may fail, we should check it before assign values to the fields of struct btrfs_trans_handle *h.
--- transaction.h | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
transaction.h +5 -0
@@ -32,7 +32,12 @@ static inline struct btrfs_trans_handle * btrfs_start_transaction(struct btrfs_root *root, int num_blocks) {struct btrfs_fs_info *fs_info = root->fs_info; +struct btrfs_trans_handle *h =malloc (sizeof (*h)); +if (!h) { +BUG (); +return NULL ; + }BUG_ON (root->commit_root);BUG_ON (fs_info->running_transaction);
Signature · 1 line
1.7.1
Quoted 13 lines · Wang Sheng-Hui
For malloc may fail, we should check it before assign values to the fields of struct
btrfs_trans_handle*h.Signed-off-by Wang Sheng-Hui <[email protected]>--- transaction.h | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)transaction.h +0
-0
transaction.h static inline struct btrfs_trans_handle * · line 40
Quoted 9 lines
transaction.h +5
-0@@ -32,7 +32,12 @@ static inline struct btrfs_trans_handle * btrfs_start_transaction(struct btrfs_root *root, int num_blocks) {struct btrfs_fs_info *fs_info = root->fs_info; +struct btrfs_trans_handle *h =malloc (sizeof (*h)); +if (!h) { +BUG (); +return NULL ; + }
a more simple way would be to writeBUG_ON(!h);
Quoted 3 lines
transaction.h +0
-0BUG_ON (root->commit_root);BUG_ON (fs_info->running_transaction);
Quoted 9 lines · Arne Jansen
Quoted 8 lines · Wang Sheng-Hui
For malloc may fail, we should check it before assign values to the fields of struct
btrfs_trans_handle*h.Signed-off-by Wang Sheng-Hui <[email protected]>--- transaction.h | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
Quoted 9 lines
transaction.h static inline struct btrfs_trans_handle * · line 35
Quoted 9 lines
transaction.h +1
-0@@ -32,7 +32,12 @@ static inline struct btrfs_trans_handle * btrfs_start_transaction(struct btrfs_root *root, int num_blocks) {struct btrfs_fs_info *fs_info = root->fs_info; +
Why move down a blank line?
Quoted 1 line
transaction.h static inline struct btrfs_trans_handle * · line 36
Quoted 1 line
transaction.h +0
-0struct btrfs_trans_handle *h =malloc (sizeof (*h));
Skip a line here would looks a bit neat.
Quoted 14 lines
transaction.h static inline struct btrfs_trans_handle * · line 40
Quoted 4 lines
transaction.h +4
-0+if (!h) { +BUG (); +return NULL ; + }a more simple way would be to write
BUG_ON(!h);transaction.h static inline struct btrfs_trans_handle * · line 43
Quoted 3 lines
transaction.h +0
-0BUG_ON (root->commit_root);BUG_ON (fs_info->running_transaction);--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 20 lines · Jie Liu
Quoted 9 lines · Arne Jansen
Quoted 8 lines · Wang Sheng-Hui
For malloc may fail, we should check it before assign values to the fields of struct
btrfs_trans_handle*h.Signed-off-by Wang Sheng-Hui <[email protected]>--- transaction.h | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)Quoted 9 lines
transaction.h static inline struct btrfs_trans_handle * · line 35
Quoted 9 lines
transaction.h +1
-0@@ -32,7 +32,12 @@ static inline struct btrfs_trans_handle * btrfs_start_transaction(struct btrfs_root *root, int num_blocks) {struct btrfs_fs_info *fs_info = root->fs_info; +Why move down a blank line?
Quoted 17 lines
Quoted 1 line
transaction.h static inline struct btrfs_trans_handle * · line 36
Quoted 1 line
transaction.h +0
-0struct btrfs_trans_handle *h =malloc (sizeof (*h));Skip a line here would looks a bit neat.
Quoted 14 lines
transaction.h static inline struct btrfs_trans_handle * · line 40
Quoted 4 lines
transaction.h +4
-0+if (!h) { +BUG (); +return NULL ; + }a more simple way would be to write
BUG_ON(!h);transaction.h static inline struct btrfs_trans_handle * · line 42
Quoted 3 lines
transaction.h +0
-0BUG_ON (root->commit_root);BUG_ON (fs_info->running_transaction);--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Patch regenerated. Please check it. Thanks,
Quoted 1 line
From
5a265e252e87a8a456a6615affd57dfb49900c64Mon Sep 17 00:00:00 2001
From: Wang Sheng-Hui <[email protected]>
Date: Thu, 16 Aug 2012 20:14:32 +0800
Subject: [PATCH] btrfs-progs: add malloc check in transaction.h/btrfs_start_transaction
For malloc may fail, we should check it before assign values to the struct btrfs_trans_handle *h.
--- transaction.h | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
transaction.h +1 -0
@@ -34,6 +34,7 @@ btrfs_start_transaction(struct btrfs_root *root, int num_blocks)struct btrfs_fs_info *fs_info = root->fs_info;struct btrfs_trans_handle *h =malloc (sizeof (*h)); +BUG_ON (!h);BUG_ON (root->commit_root);BUG_ON (fs_info->running_transaction); fs_info->running_transaction = h;
Signature · 1 line
1.7.1