Skip to content

Commit e316447

Browse files
David Weneigenmatt
David Wen
authored andcommitted
4.16 and 4.17 kernel panic fix
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.
1 parent ec89f4d commit e316447

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

modules/exanic/exanic-i2c.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,7 @@ exanic_i2c_bus_register(struct exanic *exanic, int port,
550550
data->bit_data.udelay = 20;
551551
data->bit_data.timeout = HZ;
552552
data->bit_data.data = data;
553+
data->exanic = exanic;
553554

554555
/* fill in i2c adapter */
555556
adap->owner = THIS_MODULE;
@@ -564,8 +565,6 @@ exanic_i2c_bus_register(struct exanic *exanic, int port,
564565
data->xfer_wrapped = adap->algo->master_xfer;
565566
exanic_i2c_bit_algo.functionality = adap->algo->functionality;
566567
adap->algo = &exanic_i2c_bit_algo;
567-
568-
data->exanic = exanic;
569568
/* add to bus list */
570569
list_add_tail(&data->link, &exanic->i2c_list);
571570

0 commit comments

Comments
 (0)