Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1628975

[PATCH 1/1] char: xillybus: check return value

From Pan Bian <bianpan201602@163.com>
Newsgroups linux.kernel
Subject [PATCH 1/1] char: xillybus: check return value
Date 2017-04-23 12:20 +0200
Message-ID <tzmMx-7cq-5@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


From: Pan Bian <bianpan2016@163.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@163.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

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH 1/1] char: xillybus: check return value Pan Bian <bianpan201602@163.com> - 2017-04-23 12:20 +0200

csiph-web