Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

soundwire: Fix a signedness bug

"ret" is an int and "buf" is a u8. sdw_read() returns negative error
codes which are truncated to the u8, 0-255 range before being stored as
an int. It means that "ret" can't be less than zero.

Fixes: b0a9c37b0178 ("soundwire: Add slave status handling")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Dan Carpenter and committed by
Greg Kroah-Hartman
51c26656 d6088e9a

+2 -2
+2 -2
drivers/soundwire/bus.c
··· 771 771 sdw_modify_slave_status(slave, SDW_SLAVE_ALERT); 772 772 773 773 /* Read Instat 1, Instat 2 and Instat 3 registers */ 774 - ret = buf = sdw_read(slave, SDW_SCP_INT1); 774 + buf = ret = sdw_read(slave, SDW_SCP_INT1); 775 775 if (ret < 0) { 776 776 dev_err(slave->bus->dev, 777 777 "SDW_SCP_INT1 read failed:%d", ret); ··· 870 870 * Read status again to ensure no new interrupts arrived 871 871 * while servicing interrupts. 872 872 */ 873 - ret = _buf = sdw_read(slave, SDW_SCP_INT1); 873 + _buf = ret = sdw_read(slave, SDW_SCP_INT1); 874 874 if (ret < 0) { 875 875 dev_err(slave->bus->dev, 876 876 "SDW_SCP_INT1 read failed:%d", ret);