]> git.itanic.dy.fi Git - linux-stable/commit
coresight: Fix signedness bug in tmc_etr_buf_insert_barrier_packet()
authorDan Carpenter <dan.carpenter@linaro.org>
Fri, 21 Apr 2023 10:42:41 +0000 (13:42 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 30 May 2023 11:44:10 +0000 (12:44 +0100)
commit9b13972e4f236936fe074f81e9f63b1fe0cd64bb
treeacec3a59fc090c6a366987e1d88f3f27e89e5dbc
parentf6b610730e8f5f3d98af378fbe374966eaad025f
coresight: Fix signedness bug in tmc_etr_buf_insert_barrier_packet()

commit f67bc15e526bb9920683ad6c1891ff9e08981335 upstream.

This code generates a Smatch warning:

    drivers/hwtracing/coresight/coresight-tmc-etr.c:947 tmc_etr_buf_insert_barrier_packet()
    error: uninitialized symbol 'bufp'.

The problem is that if tmc_sg_table_get_data() returns -EINVAL, then
when we test if "len < CORESIGHT_BARRIER_PKT_SIZE", the negative "len"
value is type promoted to a high unsigned long value which is greater
than CORESIGHT_BARRIER_PKT_SIZE.  Fix this bug by adding an explicit
check for error codes.

Fixes: 75f4e3619fe2 ("coresight: tmc-etr: Add transparent buffer management")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Link: https://lore.kernel.org/r/7d33e244-d8b9-4c27-9653-883a13534b01@kili.mountain
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/hwtracing/coresight/coresight-tmc-etr.c