From: Dominique Martinet Date: Tue, 14 Aug 2018 02:43:48 +0000 (+0000) Subject: 9p/xen: fix check for xenbus_read error in front_probe X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=2f9ad0ac947ccbe3ffe7c6229c9330f2a7755f64;p=openwrt%2Fstaging%2Fblogic.git 9p/xen: fix check for xenbus_read error in front_probe If the xen bus exists but does not expose the proper interface, it is possible to get a non-zero length but still some error, leading to strcmp failing trying to load invalid memory addresses e.g. fffffffffffffffe. There is then no need to check length when there is no error, as the xenbus driver guarantees that the string is nul-terminated. Link: http://lkml.kernel.org/r/1534236007-10170-1-git-send-email-asmadeus@codewreck.org Signed-off-by: Dominique Martinet Reviewed-by: Stefano Stabellini Cc: Eric Van Hensbergen Cc: Latchesar Ionkov --- diff --git a/net/9p/trans_xen.c b/net/9p/trans_xen.c index c2d54ac76bfd..843cb823d9b9 100644 --- a/net/9p/trans_xen.c +++ b/net/9p/trans_xen.c @@ -391,8 +391,8 @@ static int xen_9pfs_front_probe(struct xenbus_device *dev, unsigned int max_rings, max_ring_order, len = 0; versions = xenbus_read(XBT_NIL, dev->otherend, "versions", &len); - if (!len) - return -EINVAL; + if (IS_ERR(versions)) + return PTR_ERR(versions); if (strcmp(versions, "1")) { kfree(versions); return -EINVAL;