[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1492942249-25142-1-git-send-email-bianpan201602@163.com>
Date: Sun, 23 Apr 2017 18:10:49 +0800
From: Pan Bian <bianpan201602@....com>
To: Eli Billauer <eli.billauer@...il.com>
Cc: linux-kernel@...r.kernel.org, Pan Bian <bianpan2016@....com>
Subject: [PATCH 1/1] char: xillybus: check return value
From: Pan Bian <bianpan2016@....com>
Function of_address_to_resource() tries to translate device tree address
and return as resource. If the translation fails, it will return a
negative errno. However, function xilly_drv_probe() does not validate
its return value, which may result in a bad memory access bug. This
patch fixes the bug.
Signed-off-by: Pan Bian <bianpan2016@....com>
---
drivers/char/xillybus/xillybus_of.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/char/xillybus/xillybus_of.c b/drivers/char/xillybus/xillybus_of.c
index 78a492f..57b295a 100644
--- a/drivers/char/xillybus/xillybus_of.c
+++ b/drivers/char/xillybus/xillybus_of.c
@@ -137,6 +137,8 @@ static int xilly_drv_probe(struct platform_device *op)
dev_set_drvdata(dev, endpoint);
rc = of_address_to_resource(dev->of_node, 0, &res);
+ if (rc < 0)
+ return rc;
endpoint->registers = devm_ioremap_resource(dev, &res);
if (IS_ERR(endpoint->registers))
--
1.9.1
Powered by blists - more mailing lists