* [PATCH 1/3] soundwire: fix sign extension when shifting buf[2] 24 places
@ 2018-01-08 16:52 Vinod Koul
2018-01-08 16:52 ` [PATCH 2/3] soundwire: intel: fix missing assignment to ret Vinod Koul
2018-01-08 16:52 ` [PATCH 3/3] soundwire: Fix typo in return value check of sdw_read() Vinod Koul
0 siblings, 2 replies; 3+ messages in thread
From: Vinod Koul @ 2018-01-08 16:52 UTC (permalink / raw)
To: Greg KH; +Cc: LKML, Sanyog Kale, Colin Ian King
From: Colin Ian King <colin.king@canonical.com>
The buf[2] left shift by 24 bits is promoted to int (32 bit signed)
and then signed-extended to unsigned long long. Hence if the upper
bit to buf[2] is set then all the upper bits of addr end up as 1.
Fix this by casting it to u64 before shifting it. Also replace the
unsigned long long casts to u64 casts to match the same type of
addr.
Detected by CoverityScan, CID#1463147 ("Unintended sign extension")
Fixes: d52d7a1be02c ("soundwire: Add Slave status handling helpers")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Vinod Koul <vinod.koul@intel.com>
---
drivers/soundwire/bus.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c
index 4c345197eb55..7211ecc62015 100644
--- a/drivers/soundwire/bus.c
+++ b/drivers/soundwire/bus.c
@@ -522,8 +522,8 @@ static int sdw_program_device_num(struct sdw_bus *bus)
* bits to avoid truncation due to size limit.
*/
addr = buf[5] | (buf[4] << 8) | (buf[3] << 16) |
- (buf[2] << 24) | ((unsigned long long)buf[1] << 32) |
- ((unsigned long long)buf[0] << 40);
+ ((u64)buf[2] << 24) | ((u64)buf[1] << 32) |
+ ((u64)buf[0] << 40);
sdw_extract_slave_id(bus, addr, &id);
--
2.7.4
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/3] soundwire: intel: fix missing assignment to ret
2018-01-08 16:52 [PATCH 1/3] soundwire: fix sign extension when shifting buf[2] 24 places Vinod Koul
@ 2018-01-08 16:52 ` Vinod Koul
2018-01-08 16:52 ` [PATCH 3/3] soundwire: Fix typo in return value check of sdw_read() Vinod Koul
1 sibling, 0 replies; 3+ messages in thread
From: Vinod Koul @ 2018-01-08 16:52 UTC (permalink / raw)
To: Greg KH; +Cc: LKML, Sanyog Kale, Colin Ian King
From: Colin Ian King <colin.king@canonical.com>
Currently the return status ret is being checked but it has not been
updated since the previous check on ret. It appears that assignment of
ret from return status of the call to sdw_cdns_enable_interrupt was
accidentally ommited. Fix this.
Detected by CoverityScan, CID#1463148 ("Logically dead code")
Fixes: 71bb8a1b059e ("soundwire: intel: Add Intel Master driver")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Vinod Koul <vinod.koul@intel.com>
---
drivers/soundwire/intel.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/soundwire/intel.c b/drivers/soundwire/intel.c
index 6a9177ea6eb9..86a7bd1fc912 100644
--- a/drivers/soundwire/intel.c
+++ b/drivers/soundwire/intel.c
@@ -295,7 +295,7 @@ static int intel_probe(struct platform_device *pdev)
if (ret)
goto err_init;
- sdw_cdns_enable_interrupt(&sdw->cdns);
+ ret = sdw_cdns_enable_interrupt(&sdw->cdns);
if (ret)
goto err_init;
--
2.7.4
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 3/3] soundwire: Fix typo in return value check of sdw_read()
2018-01-08 16:52 [PATCH 1/3] soundwire: fix sign extension when shifting buf[2] 24 places Vinod Koul
2018-01-08 16:52 ` [PATCH 2/3] soundwire: intel: fix missing assignment to ret Vinod Koul
@ 2018-01-08 16:52 ` Vinod Koul
1 sibling, 0 replies; 3+ messages in thread
From: Vinod Koul @ 2018-01-08 16:52 UTC (permalink / raw)
To: Greg KH; +Cc: LKML, Sanyog Kale, Wei Yongjun
From: Wei Yongjun <weiyongjun1@huawei.com>
Fix the typo, 'status' should be instead of 'status2'.
Fixes: b0a9c37b0178 ("soundwire: Add slave status handling")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Acked-by: Vinod Koul <vinod.koul@intel.com>
---
drivers/soundwire/bus.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c
index 7211ecc62015..03313590b661 100644
--- a/drivers/soundwire/bus.c
+++ b/drivers/soundwire/bus.c
@@ -671,8 +671,8 @@ static int sdw_handle_dp0_interrupt(struct sdw_slave *slave, u8 *slave_status)
status2 = sdw_read(slave, SDW_DP0_INT);
if (status2 < 0) {
dev_err(slave->bus->dev,
- "SDW_DP0_INT read failed:%d", status);
- return status;
+ "SDW_DP0_INT read failed:%d", status2);
+ return status2;
}
status &= status2;
@@ -741,10 +741,10 @@ static int sdw_handle_port_interrupt(struct sdw_slave *slave,
/* Read DPN interrupt again */
status2 = sdw_read(slave, addr);
- if (status < 0) {
+ if (status2 < 0) {
dev_err(slave->bus->dev,
- "SDW_DPN_INT read failed:%d", status);
- return status;
+ "SDW_DPN_INT read failed:%d", status2);
+ return status2;
}
status &= status2;
--
2.7.4
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-01-08 16:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-08 16:52 [PATCH 1/3] soundwire: fix sign extension when shifting buf[2] 24 places Vinod Koul
2018-01-08 16:52 ` [PATCH 2/3] soundwire: intel: fix missing assignment to ret Vinod Koul
2018-01-08 16:52 ` [PATCH 3/3] soundwire: Fix typo in return value check of sdw_read() Vinod Koul
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®