Merge "i2c-msm-v2: Add NULL pointer check on i2c messages"

This commit is contained in:
Linux Build Service Account 2019-09-05 23:59:03 -07:00 committed by Gerrit - the friendly Code Review server
commit f2a437b52b

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2014-2018, The Linux Foundation. All rights reserved. /* Copyright (c) 2014-2019, The Linux Foundation. All rights reserved.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and * it under the terms of the GNU General Public License version 2 and
@ -2155,8 +2155,12 @@ static bool i2c_msm_xfer_next_buf(struct i2c_msm_ctrl *ctrl)
{ {
struct i2c_msm_xfer_buf *cur_buf = &ctrl->xfer.cur_buf; struct i2c_msm_xfer_buf *cur_buf = &ctrl->xfer.cur_buf;
struct i2c_msg *cur_msg = ctrl->xfer.msgs + cur_buf->msg_idx; struct i2c_msg *cur_msg = ctrl->xfer.msgs + cur_buf->msg_idx;
int bc_rem = cur_msg->len - cur_buf->end_idx; int bc_rem = 0;
if (!cur_msg)
return false;
bc_rem = cur_msg->len - cur_buf->end_idx;
if (cur_buf->is_init && cur_buf->end_idx && bc_rem) { if (cur_buf->is_init && cur_buf->end_idx && bc_rem) {
/* not the first buffer in a message */ /* not the first buffer in a message */
@ -2330,17 +2334,12 @@ i2c_msm_frmwrk_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
struct i2c_msm_ctrl *ctrl = i2c_get_adapdata(adap); struct i2c_msm_ctrl *ctrl = i2c_get_adapdata(adap);
struct i2c_msm_xfer *xfer = &ctrl->xfer; struct i2c_msm_xfer *xfer = &ctrl->xfer;
if (num < 1) { if (IS_ERR_OR_NULL(msgs) || num < 1) {
dev_err(ctrl->dev, dev_err(ctrl->dev,
"error on number of msgs(%d) received\n", num); "Error on msgs Accessing invalid message pointer or message buffer\n");
return -EINVAL; return -EINVAL;
} }
if (IS_ERR_OR_NULL(msgs)) {
dev_err(ctrl->dev, " error on msgs Accessing invalid pointer location\n");
return PTR_ERR(msgs);
}
/* if system is suspended just bail out */ /* if system is suspended just bail out */
if (ctrl->pwr_state == I2C_MSM_PM_SYS_SUSPENDED) { if (ctrl->pwr_state == I2C_MSM_PM_SYS_SUSPENDED) {
dev_err(ctrl->dev, dev_err(ctrl->dev,