All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/1] sandbox: host bind must close file descriptor
@ 2021-02-02 23:21 Heinrich Schuchardt
  2021-02-03 21:42 ` Simon Glass
  2021-02-07  0:17 ` Simon Glass
  0 siblings, 2 replies; 3+ messages in thread
From: Heinrich Schuchardt @ 2021-02-02 23:21 UTC (permalink / raw)
  To: u-boot

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>
---
v2:
	remove superfluous data checking
---
 drivers/block/sandbox.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/block/sandbox.c b/drivers/block/sandbox.c
index f57f690d3c..ac20ff6493 100644
--- a/drivers/block/sandbox.c
+++ b/drivers/block/sandbox.c
@@ -230,6 +230,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,
@@ -239,6 +251,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
--
2.30.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH v2 1/1] sandbox: host bind must close file descriptor
  2021-02-02 23:21 [PATCH v2 1/1] sandbox: host bind must close file descriptor Heinrich Schuchardt
@ 2021-02-03 21:42 ` Simon Glass
  2021-02-07  0:17 ` Simon Glass
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Glass @ 2021-02-03 21:42 UTC (permalink / raw)
  To: u-boot

On Tue, 2 Feb 2021 at 16:22, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> 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>
> ---
> v2:
>         remove superfluous data checking
> ---
>  drivers/block/sandbox.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v2 1/1] sandbox: host bind must close file descriptor
  2021-02-02 23:21 [PATCH v2 1/1] sandbox: host bind must close file descriptor Heinrich Schuchardt
  2021-02-03 21:42 ` Simon Glass
@ 2021-02-07  0:17 ` Simon Glass
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Glass @ 2021-02-07  0:17 UTC (permalink / raw)
  To: u-boot

On Tue, 2 Feb 2021 at 16:22, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> 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>
> ---
> v2:
>         remove superfluous data checking
> ---
>  drivers/block/sandbox.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-02-07  0:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-02 23:21 [PATCH v2 1/1] sandbox: host bind must close file descriptor Heinrich Schuchardt
2021-02-03 21:42 ` Simon Glass
2021-02-07  0:17 ` Simon Glass

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.