From 2ed55f746c4223b5d7dfcddb2aa3029dc8e7439b Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Mon, 14 Sep 2020 12:05:47 +0200 Subject: sandbox: hostfile: error out if file couldn't be opened The file descriptor is mandatory for doing anything useful. Error out if we don't have one. Signed-off-by: Ahmad Fatoum Signed-off-by: Sascha Hauer --- arch/sandbox/board/hostfile.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'arch/sandbox/board') diff --git a/arch/sandbox/board/hostfile.c b/arch/sandbox/board/hostfile.c index 5f0d7e0a4b..56023b4ad4 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; -- cgit v1.2.3