From patchwork Tue Feb 2 23:21: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: 1435022 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=85.214.62.61; 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=DVdodURJ; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (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 4DVgns3FGNz9tlJ for ; Wed, 3 Feb 2021 10:22:18 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 427D1826FB; Wed, 3 Feb 2021 00:22:09 +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="DVdodURJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B52ED8270D; Wed, 3 Feb 2021 00:22: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.22]) (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 672688267E for ; Wed, 3 Feb 2021 00:22:03 +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=1612308122; bh=LpOMEjWqDGbVMRl240nQznTZW8Da4iqbReKMbYgQlFY=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date; b=DVdodURJs025gvlmYZafaEROT8hnnSt3qh2zRoLK20cQpneBbLGjFhygcVKrYjpPT J6fdF9RpuFsNOJbQth7Tcba1RhGKFy0oGThUfK5pCZersmF9u1/xm22Rskwm9oTJN9 YutZhv8Jh0imtjb0MjMPFOZR/tTg2/d/TDx6lFuU= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from workstation4.fritz.box ([62.143.246.89]) by mail.gmx.net (mrgmx104 [212.227.17.174]) with ESMTPSA (Nemesis) id 1MEm6F-1l9Yu10ZqN-00GKaN; Wed, 03 Feb 2021 00:22:02 +0100 From: Heinrich Schuchardt To: Simon Glass Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: [PATCH v2 1/1] sandbox: host bind must close file descriptor Date: Wed, 3 Feb 2021 00:21:56 +0100 Message-Id: <20210202232156.323871-1-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 X-Provags-ID: V03:K1:SgxhMg7SeZh0hti10Da5Bh8wHDWHcNiFYRiz3HMFOc2ma9qh2v0 VO1zzhxxWoFTODcRtcdcXNVyaotSvU/vspY/XXGH6ombTZ5EAhmU0MBcsp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-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 Reviewed-by: Simon Glass Reviewed-by: Simon Glass --- v2: remove superfluous data checking --- drivers/block/sandbox.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) -- 2.30.0 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