summaryrefslogtreecommitdiff
path: root/drivers/i2c
diff options
context:
space:
mode:
authorColin Ian King <colin.king@canonical.com>2017-03-20 11:51:23 +0000
committerWolfram Sang <wsa@the-dreams.de>2017-04-19 21:00:13 +0200
commitc7f82ea8605627b3088f166d9f4a5ca7857e8383 (patch)
tree237b2399914d3db7e9e268cb23b1a84ecdf90542 /drivers/i2c
parentbd698d24b1b5790d0a22d44a0705dabd47235ad4 (diff)
i2c: designware-baytrail: fix potential null pointer dereference on dev
The assignment to addr requires a call to get_sem_addr that dereferences dev, however, this dereference occurs before a null pointer check on dev. Move this assignment after the null check on dev to avoid a potential null pointer dereference. Detected by CoverityScan, CID#1419700 ("Dereference before null check") Fixes: fd476fa22a1f432 ("i2c: designware-baytrail: Add support for cherrytrail") Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/busses/i2c-designware-baytrail.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/i2c/busses/i2c-designware-baytrail.c b/drivers/i2c/busses/i2c-designware-baytrail.c
index 1ac042972020..dbda8c9c8a1c 100644
--- a/drivers/i2c/busses/i2c-designware-baytrail.c
+++ b/drivers/i2c/busses/i2c-designware-baytrail.c
@@ -70,7 +70,7 @@ static void reset_semaphore(struct dw_i2c_dev *dev)
static int baytrail_i2c_acquire(struct dw_i2c_dev *dev)
{
- u32 addr = get_sem_addr(dev);
+ u32 addr;
u32 sem = PUNIT_SEMAPHORE_ACQUIRE;
int ret;
unsigned long start, end;
@@ -94,6 +94,8 @@ static int baytrail_i2c_acquire(struct dw_i2c_dev *dev)
*/
pm_qos_update_request(&dev->pm_qos, 0);
+ addr = get_sem_addr(dev);
+
/* host driver writes to side band semaphore register */
ret = iosf_mbi_write(BT_MBI_UNIT_PMC, MBI_REG_WRITE, addr, sem);
if (ret) {