]> git.hungrycats.org Git - linux/commit
block/rnbd-srv: don't free the device on a sysfs error
authorJosef Bacik <josef@toxicpanda.com>
Wed, 28 Oct 2026 16:41:19 +0000 (10:41 -0600)
committerJens Axboe <axboe@kernel.dk>
Thu, 29 Oct 2026 13:23:19 +0000 (07:23 -0600)
commitd9667ade40f986c565769a900ced6ee95edd33c6
tree1369e72009e20f55b0cbb89553810f5fba4557f2
parentbf7fff620c890a7ee0b444f1c7e9f0d1263a30ac
block/rnbd-srv: don't free the device on a sysfs error

rnbd_srv_create_dev_sysfs() drops the only kobject reference on its
error paths, and the release function frees the rnbd_srv_dev.
process_msg_open() keeps using it and ends in destroy_device() with a
list_del() and a second kfree(). This doesn't need memory pressure: a
client opening a device while its last mapping goes away gets -EEXIST
from kobject_add() against the old directory.

Only undo kobject_add() on failure and leave the reference to
destroy_device(). Initialise the kobject once, the next open retries.

Fixes: 8cee532f469b ("block/rnbd: server: sysfs interface functions")
Fixes: d3a95ccaaf4d ("block/rnbd: call kobject_put in the failure path")
Cc: "Md. Haris Iqbal" <haris.iqbal@ionos.com>
Cc: Jack Wang <jinpu.wang@ionos.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Link: https://patch.msgid.link/20261028164415.1262013-17-axboe@kernel.dk
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/rnbd/rnbd-srv-sysfs.c
drivers/block/rnbd/rnbd-srv.c