Skip to content

i2c: Check return value of get_i2c_port() #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: fwk-hx20-hx30-4410
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion common/i2c_master.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ static int chip_i2c_xfer_with_notify(const int port,
int ret;
uint16_t addr_flags = slave_addr_flags;
const struct i2c_port_t *i2c_port = get_i2c_port(port);
ASSERT(i2c_port);

if (IS_ENABLED(CONFIG_I2C_XFER_BOARD_CALLBACK))
i2c_start_xfer_notify(port, slave_addr_flags);
Expand Down Expand Up @@ -1011,7 +1012,7 @@ int i2c_set_freq(int port, enum i2c_freq freq)
{
int ret;

if (!(get_i2c_port(port)->flags & I2C_PORT_FLAG_DYNAMIC_SPEED))
if (get_i2c_port(port) && !(get_i2c_port(port)->flags & I2C_PORT_FLAG_DYNAMIC_SPEED))
return EC_ERROR_INVAL;

i2c_lock(port, 1);
Expand Down