diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2019-04-23 06:40:20 -0400 |
---|---|---|
committer | Boris Brezillon <boris.brezillon@collabora.com> | 2019-05-06 02:15:02 -0400 |
commit | 476c7e1d34f2a03b1aa5a924c50703053fe5f77c (patch) | |
tree | 4b78b80c72c9e9a18e0bd34f352696b330af5f11 /drivers/i3c | |
parent | 124dbd750da4a9bf494ae9d8cbed364058140731 (diff) |
i3c: Fix a shift wrap bug in i3c_bus_set_addr_slot_status()
The problem here is that addr can be I3C_BROADCAST_ADDR (126). That
means we're shifting by (126 * 2) % 64 which is 60. The
I3C_ADDR_SLOT_STATUS_MASK is an enum which is an unsigned int in GCC
so shifts greater than 31 are undefined.
Fixes: 3a379bbcea0a ("i3c: Add core I3C infrastructure")
Cc: <stable@vger.kernel.org>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Diffstat (limited to 'drivers/i3c')
-rw-r--r-- | drivers/i3c/master.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c index 2dc628d4f1ae..d539252eed79 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c | |||
@@ -385,8 +385,9 @@ static void i3c_bus_set_addr_slot_status(struct i3c_bus *bus, u16 addr, | |||
385 | return; | 385 | return; |
386 | 386 | ||
387 | ptr = bus->addrslots + (bitpos / BITS_PER_LONG); | 387 | ptr = bus->addrslots + (bitpos / BITS_PER_LONG); |
388 | *ptr &= ~(I3C_ADDR_SLOT_STATUS_MASK << (bitpos % BITS_PER_LONG)); | 388 | *ptr &= ~((unsigned long)I3C_ADDR_SLOT_STATUS_MASK << |
389 | *ptr |= status << (bitpos % BITS_PER_LONG); | 389 | (bitpos % BITS_PER_LONG)); |
390 | *ptr |= (unsigned long)status << (bitpos % BITS_PER_LONG); | ||
390 | } | 391 | } |
391 | 392 | ||
392 | static bool i3c_bus_dev_addr_is_avail(struct i3c_bus *bus, u8 addr) | 393 | static bool i3c_bus_dev_addr_is_avail(struct i3c_bus *bus, u8 addr) |