From patchwork Sun Jan 31 10:38:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 1433830 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.a=rsa-sha256 header.s=badeba3b8450 header.b=IZ/3AtI6; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DT6yS5CSSz9sCD for ; Sun, 31 Jan 2021 21:39:21 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C7AA782369; Sun, 31 Jan 2021 11:39:08 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.b="IZ/3AtI6"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 47BC08239D; Sun, 31 Jan 2021 11:39:06 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id CB9FF82361 for ; Sun, 31 Jan 2021 11:39:01 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=xypron.glpk@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1612089541; bh=JSKAEArEkHOB75W3054BpM4z3ONo3PpjxeIfrvVISuM=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date; b=IZ/3AtI6U7u/GwheM0+UMaDZ1mCvKSZUbL9B5izo7i0dRXKaVgUc7CURVK4DskXaP rALfyp0YmQJuHfu3zqnTmgnTW6xkx/HXK1ALxuc0A7XkHDqw9x1auDL5UVt50niYMo IAPhOSfcZu0w3RbFx1teH9BDO/VWScfOEqdsyJA4= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from LT02.fritz.box ([62.143.246.89]) by mail.gmx.net (mrgmx105 [212.227.17.174]) with ESMTPSA (Nemesis) id 1M5QFB-1l5LJh3Ryf-001Q7B; Sun, 31 Jan 2021 11:39:00 +0100 From: Heinrich Schuchardt To: Simon Glass Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: [PATCH 1/1] sandbox: host bind must close file descriptor Date: Sun, 31 Jan 2021 11:38:56 +0100 Message-Id: <20210131103856.80651-1-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 X-Provags-ID: V03:K1:nqvy9xUSZGsWmssPAj8+bGZUAbwyV0Z2o/Zs97+E2t5So44WqrC dK+yr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mjZ54he/2zAPAGFs8X4dL8cK07EsQhLMD2saHGfsKkgamRJ GePWF1dUafsM/DvXQOmw== X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean 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 --- drivers/block/sandbox.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) -- 2.29.2 diff --git a/drivers/block/sandbox.c b/drivers/block/sandbox.c index f57f690d3c..02992ac34f 100644 --- a/drivers/block/sandbox.c +++ b/drivers/block/sandbox.c @@ -230,6 +230,25 @@ 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; + + host_dev = dev_get_plat(dev); + if (host_dev) { + if (host_dev->fd) { + os_close(host_dev->fd); + host_dev->fd = 0; + } else { + log_err("missing file descriptor\n"); + } + } else { + log_err("missing platform data\n"); + } + return 0; +} + static const struct blk_ops sandbox_host_blk_ops = { .read = host_block_read, .write = host_block_write, @@ -239,6 +258,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