提交 3be6bd69 编写于 作者: A Anton Vasilyev 提交者: Guenter Roeck

hwmon: (stts751) buffer overrun on wrong chip configuration

If stts751 hw by some reason reports conversion rate bigger then 9:
        ret = i2c_smbus_read_byte_data(priv->client, STTS751_REG_RATE);
then dereferencing stts751_intervals[priv->interval] leads to buffer
overrun.

The patch adds sanity check for value stored on chip.

Found by Linux Driver Verification project (linuxtesting.org).

Fixes: 7f07ec0f ("hwmon: new driver for ST stts751 thermal sensor")
Signed-off-by: NAnton Vasilyev <vasilyev@ispras.ru>
Signed-off-by: NGuenter Roeck <linux@roeck-us.net>
上级 7576750f
......@@ -718,6 +718,10 @@ static int stts751_read_chip_config(struct stts751_priv *priv)
ret = i2c_smbus_read_byte_data(priv->client, STTS751_REG_RATE);
if (ret < 0)
return ret;
if (ret >= ARRAY_SIZE(stts751_intervals)) {
dev_err(priv->dev, "Unrecognized conversion rate 0x%x\n", ret);
return -ENODEV;
}
priv->interval = ret;
ret = stts751_read_reg16(priv, &priv->event_max,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册