summaryrefslogtreecommitdiffstats
path: root/fs/tftp.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2018-11-29 11:17:08 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2018-11-29 15:04:31 +0100
commit4b48ae4bcdbc137c80b77adc5aa614e5f4cb9f51 (patch)
treeec502443c6dd7e665a8b420d49eb5ae811de7775 /fs/tftp.c
parentcd9a7567b0d5afd874dcd31fd22918868e9eab9e (diff)
downloadbarebox-4b48ae4bcdbc137c80b77adc5aa614e5f4cb9f51.tar.gz
barebox-4b48ae4bcdbc137c80b77adc5aa614e5f4cb9f51.tar.xz
net: dns: return error codes
The resolv() function used to return the IP address. When net_udp_new() fails we return an error code though which the callers of resolv() take as an IP address. This is wrong of course and we could return 0 in this case. Instead we return an error code and pass the resolved IP as a pointer which allows us to return proper error codes. This patch also adds error messages and error returns to the various callers of resolv() which used to just continue with a zero IP and let the user figure out what went wrong. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'fs/tftp.c')
-rw-r--r--fs/tftp.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/fs/tftp.c b/fs/tftp.c
index 0d9ee6effd..907adc7434 100644
--- a/fs/tftp.c
+++ b/fs/tftp.c
@@ -696,10 +696,15 @@ static int tftp_probe(struct device_d *dev)
struct tftp_priv *priv = xzalloc(sizeof(struct tftp_priv));
struct super_block *sb = &fsdev->sb;
struct inode *inode;
+ int ret;
dev->priv = priv;
- priv->server = resolv(fsdev->backingstore);
+ ret = resolv(fsdev->backingstore, &priv->server);
+ if (ret) {
+ pr_err("Cannot resolve \"%s\": %s\n", fsdev->backingstore, strerror(-ret));
+ goto err;
+ }
sb->s_op = &tftp_ops;
@@ -707,6 +712,10 @@ static int tftp_probe(struct device_d *dev)
sb->s_root = d_make_root(inode);
return 0;
+err:
+ free(priv);
+
+ return ret;
}
static void tftp_remove(struct device_d *dev)