[PATCH master 1/7] sandbox: hostfile: error out if file couldn't be opened

Ahmad Fatoum a.fatoum at pengutronix.de
Mon Sep 14 06:05:47 EDT 2020


The file descriptor is mandatory for doing anything useful.
Error out if we don't have one.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 arch/sandbox/board/hostfile.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/sandbox/board/hostfile.c b/arch/sandbox/board/hostfile.c
index 5f0d7e0a4b28..56023b4ad45d 100644
--- a/arch/sandbox/board/hostfile.c
+++ b/arch/sandbox/board/hostfile.c
@@ -91,6 +91,9 @@ static int hf_probe(struct device_d *dev)
 	if (!priv->fd)
 		priv->fd = linux_open(priv->filename, true);
 
+	if (priv->fd < 0)
+		return priv->fd;
+
 	priv->cdev.name = dev->device_node->name;
 	priv->cdev.dev = dev;
 	priv->cdev.ops = &hf_fops;
-- 
2.28.0




More information about the barebox mailing list