summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorColin Ian King <colin.king@canonical.com>2018-01-02 20:54:19 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-01-09 19:00:13 +0300
commit7dde60c06cff611b9f88676ef9e67365dc77b19a (patch)
treeffb747668a365cf098afa0efacf7790d8aaf6e10 /drivers
parent0edff03d44009f5a459a1d3c6a7915b9952107d1 (diff)
downloadlinux-7dde60c06cff611b9f88676ef9e67365dc77b19a.tar.xz
slimbus: avoid null pointer dereference on msg
The pointer msg is checked to see if it is null at the start of the function and jumps to the error exit label reterr that then dereferences msg when it prints a dev_err error message. Avoid this potential null pointer dereference by only printing the error message if msg is not null. Detected by CoverityScan, CID#1463141 ("Dereference after null check") Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/slimbus/messaging.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/slimbus/messaging.c b/drivers/slimbus/messaging.c
index 755462a4c75e..8b2c77f516b9 100644
--- a/drivers/slimbus/messaging.c
+++ b/drivers/slimbus/messaging.c
@@ -170,8 +170,9 @@ static int slim_val_inf_sanity(struct slim_controller *ctrl,
break;
}
reterr:
- dev_err(ctrl->dev, "Sanity check failed:msg:offset:0x%x, mc:%d\n",
- msg->start_offset, mc);
+ if (msg)
+ dev_err(ctrl->dev, "Sanity check failed:msg:offset:0x%x, mc:%d\n",
+ msg->start_offset, mc);
return -EINVAL;
}