In the last iteration k equals 0, so we call platform_get_resource() with -1 as a third argument. Since platform_get_resource() uses an unsigned it is converted to 0xffffffff. platform_get_resource() fails for every index and returns NULL. A test is lacking and we dereference NULL. Also the variable q was assigned but not used. Signed-off-by: Roel Kluin <roel.kluin@xxxxxxxxx> --- drivers/i2c/busses/i2c-sh_mobile.c | 14 +++++++++----- 1 files changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/i2c/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-sh_mobile.c index ccc4641..5871335 100644 --- a/drivers/i2c/busses/i2c-sh_mobile.c +++ b/drivers/i2c/busses/i2c-sh_mobile.c @@ -496,7 +496,7 @@ static int sh_mobile_i2c_hook_irqs(struct platform_device *dev, int hook) { struct resource *res; int ret = -ENXIO; - int q, m; + int m; int k = 0; int n = 0; @@ -516,12 +516,16 @@ static int sh_mobile_i2c_hook_irqs(struct platform_device *dev, int hook) ret = 0; rollback: - for (q = k; k >= 0; k--) { - for (m = n; m >= res->start; m--) - free_irq(m, dev); + for (m = n; m >= res->start; m--) + free_irq(m, dev); + while (k--) { res = platform_get_resource(dev, IORESOURCE_IRQ, k - 1); - m = res->end; + if (res == NULL) + break; + + for (m = res->end; m >= res->start; m--) + free_irq(m, dev); } return ret; -- To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html