Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752162AbdHHNYb (ORCPT ); Tue, 8 Aug 2017 09:24:31 -0400 Received: from m12-15.163.com ([220.181.12.15]:40652 "EHLO m12-15.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752010AbdHHNY3 (ORCPT ); Tue, 8 Aug 2017 09:24:29 -0400 From: Pan Bian To: Eric Van Hensbergen , Ron Minnich , Latchesar Ionkov , "David S. Miller" Cc: v9fs-developer@lists.sourceforge.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Pan Bian Subject: xen/9pfs: check return value of xenbus_read correctly Date: Tue, 8 Aug 2017 21:23:53 +0800 Message-Id: <1502198633-27144-1-git-send-email-bianpan2016@163.com> X-Mailer: git-send-email 1.9.1 X-CM-TRANSID: D8CowACXy1l0u4lZRh0eSQ--.8861S3 X-Coremail-Antispam: 1Uf129KBjvdXoWrZr4Utr48uw1rXF4fJry8AFb_yoWfWFcEvw 48ZrZ7Wrs0qr47Z390kayYyrWUGF4DGr48A3srtayYq347ury5u3y8Xr95Ar1xWrZFk3sa vrsIv34xu3W3CjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUn6T5JUUUUU== X-Originating-IP: [106.120.213.62] X-CM-SenderInfo: held01tdqsiiqw6rljoofrz/1tbiDgUuclXlkPiRBAABsb Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 864 Lines: 26 In function xen_9pfs_front_probe(), variable len is checked against 0 to to check the case that xenbus_read() fails. However, xenbus_read() may return an ERR_PTR pointer even aften assigning a non-zero value to len. As a result, the check of len cannot prevent from accessing bad memory. Signed-off-by: Pan Bian --- net/9p/trans_xen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/9p/trans_xen.c b/net/9p/trans_xen.c index 6ad3e04..c548781 100644 --- a/net/9p/trans_xen.c +++ b/net/9p/trans_xen.c @@ -389,7 +389,7 @@ 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) + if (IS_ERR(versions)) return -EINVAL; if (strcmp(versions, "1")) { kfree(versions); -- 1.9.1