* [PATCH] i2c: designware-baytrail: fix potential null pointer dereference on dev
@ 2017-03-20 11:51 Colin King
2017-04-19 19:01 ` Wolfram Sang
0 siblings, 1 reply; 3+ messages in thread
From: Colin King @ 2017-03-20 11:51 UTC (permalink / raw)
To: Jarkko Nikula, Andy Shevchenko, Mika Westerberg, Wolfram Sang, linux-i2c
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
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>
---
drivers/i2c/busses/i2c-designware-baytrail.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/i2c/busses/i2c-designware-baytrail.c b/drivers/i2c/busses/i2c-designware-baytrail.c
index 1749a0f5a9fa..2cbb2e9195ca 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) {
--
2.11.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] i2c: designware-baytrail: fix potential null pointer dereference on dev
2017-03-20 11:51 [PATCH] i2c: designware-baytrail: fix potential null pointer dereference on dev Colin King
@ 2017-04-19 19:01 ` Wolfram Sang
0 siblings, 0 replies; 3+ messages in thread
From: Wolfram Sang @ 2017-04-19 19:01 UTC (permalink / raw)
To: Colin King
Cc: Jarkko Nikula, Andy Shevchenko, Mika Westerberg, linux-i2c,
kernel-janitors, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 632 bytes --]
On Mon, Mar 20, 2017 at 11:51:23AM +0000, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> 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>
Applied to for-next, thanks!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] i2c: designware-baytrail: fix potential null pointer dereference on dev
@ 2017-04-19 19:01 ` Wolfram Sang
0 siblings, 0 replies; 3+ messages in thread
From: Wolfram Sang @ 2017-04-19 19:01 UTC (permalink / raw)
To: Colin King
Cc: Jarkko Nikula, Andy Shevchenko, Mika Westerberg, linux-i2c,
kernel-janitors, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 632 bytes --]
On Mon, Mar 20, 2017 at 11:51:23AM +0000, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> 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>
Applied to for-next, thanks!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-04-19 19:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-20 11:51 [PATCH] i2c: designware-baytrail: fix potential null pointer dereference on dev Colin King
2017-04-19 19:01 ` Wolfram Sang
2017-04-19 19:01 ` Wolfram Sang
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.