summaryrefslogtreecommitdiff
path: root/drivers/block/sandbox.c
diff options
context:
space:
mode:
authorHeinrich Schuchardt <xypron.glpk@gmx.de>2021-02-03 00:21:56 +0100
committerSimon Glass <sjg@chromium.org>2021-03-03 19:17:25 -0700
commit297b8b3ebfc2bdeb0b245b1dbe31ae8302d9b1b8 (patch)
tree626847783fd0dd5a20aae0894055a45264ad21fd /drivers/block/sandbox.c
parent67637d4b5ab70896c8a881022126f7c61f90a0f1 (diff)
sandbox: host bind must close file descriptor
Each invocation of the 'host bind' command with a file name argument opens a file descriptor. The next invocation of the 'host bind' command destroys the block device but the file descriptor remains open. The same holds true for the 'unbind blk' command. Close the file descriptor when unbinding the host block device. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/block/sandbox.c')
-rw-r--r--drivers/block/sandbox.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/block/sandbox.c b/drivers/block/sandbox.c
index 9d7d68c007..e2f229b15d 100644
--- a/drivers/block/sandbox.c
+++ b/drivers/block/sandbox.c
@@ -231,6 +231,18 @@ int host_get_dev_err(int devnum, struct blk_desc **blk_devp)
}
#ifdef CONFIG_BLK
+
+int sandbox_host_unbind(struct udevice *dev)
+{
+ struct host_block_dev *host_dev;
+
+ /* Data validity is checked in host_dev_bind() */
+ host_dev = dev_get_plat(dev);
+ os_close(host_dev->fd);
+
+ return 0;
+}
+
static const struct blk_ops sandbox_host_blk_ops = {
.read = host_block_read,
.write = host_block_write,
@@ -240,6 +252,7 @@ U_BOOT_DRIVER(sandbox_host_blk) = {
.name = "sandbox_host_blk",
.id = UCLASS_BLK,
.ops = &sandbox_host_blk_ops,
+ .unbind = sandbox_host_unbind,
.plat_auto = sizeof(struct host_block_dev),
};
#else