Skip to content

Commit

Permalink
4.16 and 4.17 kernel panic fix
Browse files Browse the repository at this point in the history
In Linux kernel 4.16 and 4.17, the function i2c_bit_add_bus attempts to
set the clock and data signals on the i2c bus. However, the exanic
pointer was not filled in until after the bus was registered, resulting
in NULL pointer dereference.

This commit fills the exanic pointer into the i2c adapter data before
registering the bus to work around the issue.
  • Loading branch information
David Wen authored and kashuwong committed Nov 5, 2019
1 parent 9c8972a commit 0e45dba
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions modules/exanic/exanic-i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@ exanic_i2c_bus_register(struct exanic *exanic, int port,
data->bit_data.udelay = 20;
data->bit_data.timeout = HZ;
data->bit_data.data = data;
data->exanic = exanic;

/* fill in i2c adapter */
adap->owner = THIS_MODULE;
Expand All @@ -564,8 +565,6 @@ exanic_i2c_bus_register(struct exanic *exanic, int port,
data->xfer_wrapped = adap->algo->master_xfer;
exanic_i2c_bit_algo.functionality = adap->algo->functionality;
adap->algo = &exanic_i2c_bit_algo;

data->exanic = exanic;
/* add to bus list */
list_add_tail(&data->link, &exanic->i2c_list);

Expand Down

0 comments on commit 0e45dba

Please sign in to comment.