Created
February 15, 2017 13:50
-
-
Save lategoodbye/61c8c12572a27321af24e4bb10f948bd to your computer and use it in GitHub Desktop.
Avoid possible NULL pointer dereference in i2c-bcm2835
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/drivers/i2c/busses/i2c-bcm2835.c b/drivers/i2c/busses/i2c-bcm2835.c | |
index c3436f6..561090a 100644 | |
--- a/drivers/i2c/busses/i2c-bcm2835.c | |
+++ b/drivers/i2c/busses/i2c-bcm2835.c | |
@@ -195,7 +195,9 @@ static irqreturn_t bcm2835_i2c_isr(int this_irq, void *data) | |
} | |
if (val & BCM2835_I2C_S_DONE) { | |
- if (i2c_dev->curr_msg->flags & I2C_M_RD) { | |
+ if (!i2c_dev->curr_msg) { | |
+ WARN(1, "Got interrupt, but curr_msg is NULL\n"); | |
+ } else if (i2c_dev->curr_msg->flags & I2C_M_RD) { | |
bcm2835_drain_rxfifo(i2c_dev); | |
val = bcm2835_i2c_readl(i2c_dev, BCM2835_I2C_S); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment