[2/2] bcachefs: Remove a redundant and harmless bch2_free_super() call

Message ID 4318418c88f28b041af018ab2250f442cb9776ed.1694623395.git.christophe.jaillet@wanadoo.fr
State New
Headers
Series [1/2] bcachefs: Fix a potential in the error handling path of use-after-free inbch2_dev_add() |

Commit Message

Christophe JAILLET Sept. 13, 2023, 4:44 p.m. UTC
  Remove a redundant call to bch2_free_super().

This is harmless because bch2_free_super() has a memset() at its end. So
a second call would only lead to from kfree(NULL).

Remove the redundant call and only rely on the error handling path.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 fs/bcachefs/super.c | 1 -
 1 file changed, 1 deletion(-)
  

Patch

diff --git a/fs/bcachefs/super.c b/fs/bcachefs/super.c
index 7379325c428f..a9627e655666 100644
--- a/fs/bcachefs/super.c
+++ b/fs/bcachefs/super.c
@@ -1609,7 +1609,6 @@  int bch2_dev_add(struct bch_fs *c, const char *path)
 
 	ca = __bch2_dev_alloc(c, &dev_mi);
 	if (!ca) {
-		bch2_free_super(&sb);
 		ret = -ENOMEM;
 		goto err;
 	}