rbd: fix double free on rbd_dev->header_name
Subsystems (2)
Ilya Dryomov
maintainerPATCH 1/1 rbd: fix double free on rbd_dev->header_name
If rbd_dev_image_probe() in rbd_dev_probe_parent() fails, header_name is freed twice: once in rbd_dev_probe_parent() and then in its caller rbd_dev_image_probe() (rbd_dev_image_probe() is called recursively to handle parent images).
rbd_dev_probe_parent() is responsible for probing the parent, so it shoudn't mock with clone's fields.
--- drivers/block/rbd.c | 1 - 1 file changed, 1 deletion(-)
drivers/block/rbd.c +0 -1
@@ -5201,7 +5201,6 @@ static int rbd_dev_probe_parent(struct rbd_device *rbd_dev) out_err:if (parent) {rbd_dev_unparent (rbd_dev); -kfree (rbd_dev->header_name);rbd_dev_destroy (parent); }else {rbd_put_client (rbdc);
Signature · 1 line
1.9.3
Quoted 7 lines · Ilya Dryomov
If
rbd_dev_image_probe()inrbd_dev_probe_parent()fails,header_nameis freed twice: once inrbd_dev_probe_parent()and then in its callerrbd_dev_image_probe()(rbd_dev_image_probe()is called recursively to handle parent images).
rbd_dev_probe_parent()is responsible for probing the parent, so it shoudn't mock with clone's fields.
Agreed. (But I think you mean "muck with.") The other argument is that the caller is who allocated it (via rbd_dev_header_name()), so it should be responsible for freeing it.
Quoted 19 lines
Signed-off-by Ilya Dryomov <[email protected]>--- drivers/block/rbd.c | 1 - 1 file changed, 1 deletion(-)drivers/block/rbd.c +0
-1@@ -5201,7 +5201,6 @@ static int rbd_dev_probe_parent(struct rbd_device *rbd_dev) out_err:if (parent) {rbd_dev_unparent (rbd_dev); -kfree (rbd_dev->header_name);rbd_dev_destroy (parent); }else {rbd_put_client (rbdc);