]> git.itanic.dy.fi Git - linux-stable/commit
bcachefs: Fix use-after-free in bch2_dev_add()
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Wed, 13 Sep 2023 16:44:08 +0000 (18:44 +0200)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:10:13 +0000 (17:10 -0400)
commit71933fb69b7c5fe5efd2119b645d4fde337a6f3f
tree46f165913e66c9d88424e45e30ffe3483496dc3d
parenta9737e0b38352e984fc67d5694b2c207c6b9679f
bcachefs: Fix use-after-free in bch2_dev_add()

If __bch2_dev_attach_bdev() fails, bch2_dev_free() is called twice.
Once here and another time in the error handling path.

This leads to several use-after-free.

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

Fixes: 6a44735653d4 ("bcachefs: Improved superblock-related error messages")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/super.c