提交 f8c6bf5d 编写于 作者: D Dan Carpenter 提交者: Zheng Zengkai

bnxt_en: fix ternary sign extension bug in bnxt_show_temp()

stable inclusion
from stable-5.10.37
commit 66b1cfc0cd87a3c087fed66c24a3c7422d33dffe
bugzilla: 51868
CVE: NA

--------------------------------

[ Upstream commit 27537929 ]

The problem is that bnxt_show_temp() returns long but "rc" is an int
and "len" is a u32.  With ternary operations the type promotion is quite
tricky.  The negative "rc" is first promoted to u32 and then to long so
it ends up being a high positive value instead of a a negative as we
intended.

Fix this by removing the ternary.

Fixes: d69753fa ("bnxt_en: return proper error codes in bnxt_show_temp")
Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Acked-by: NWeilong Chen <chenweilong@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 26e0e9a1
......@@ -9546,7 +9546,9 @@ static ssize_t bnxt_show_temp(struct device *dev,
if (!rc)
len = sprintf(buf, "%u\n", resp->temp * 1000); /* display millidegree */
mutex_unlock(&bp->hwrm_cmd_lock);
return rc ?: len;
if (rc)
return rc;
return len;
}
static SENSOR_DEVICE_ATTR(temp1_input, 0444, bnxt_show_temp, NULL, 0);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册