Fix I2C-drivers which missed setting clientdata to NULL before freeing the
structure it points to. Also fix drivers which do this _after_ the structure
was freed already.

Signed-off-by: Wolfram Sang <[email protected]>
Cc: Richard Purdie <[email protected]>
Cc: Riku Voipio <[email protected]>
---

Found using coccinelle, then reviewed. Full patchset is available via
kernel-janitors, linux-i2c, and LKML.
---
 drivers/leds/leds-lp3944.c  |    2 +-
 drivers/leds/leds-pca9532.c |    4 ++--
 drivers/leds/leds-pca955x.c |    4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/leds/leds-lp3944.c b/drivers/leds/leds-lp3944.c
index 5946208..7dca8f2 100644
--- a/drivers/leds/leds-lp3944.c
+++ b/drivers/leds/leds-lp3944.c
@@ -425,8 +425,8 @@ static int __devexit lp3944_remove(struct i2c_client 
*client)
                        break;
                }
 
-       kfree(data);
        i2c_set_clientdata(client, NULL);
+       kfree(data);
 
        return 0;
 }
diff --git a/drivers/leds/leds-pca9532.c b/drivers/leds/leds-pca9532.c
index adc561e..0f1f8f9 100644
--- a/drivers/leds/leds-pca9532.c
+++ b/drivers/leds/leds-pca9532.c
@@ -320,8 +320,8 @@ static int pca9532_probe(struct i2c_client *client,
 
        err = pca9532_configure(client, data, pca9532_pdata);
        if (err) {
-               kfree(data);
                i2c_set_clientdata(client, NULL);
+               kfree(data);
        }
 
        return err;
@@ -349,8 +349,8 @@ static int pca9532_remove(struct i2c_client *client)
                        break;
                }
 
-       kfree(data);
        i2c_set_clientdata(client, NULL);
+       kfree(data);
        return 0;
 }
 
diff --git a/drivers/leds/leds-pca955x.c b/drivers/leds/leds-pca955x.c
index 4e2d1a4..279fc31 100644
--- a/drivers/leds/leds-pca955x.c
+++ b/drivers/leds/leds-pca955x.c
@@ -340,8 +340,8 @@ exit:
                cancel_work_sync(&pca955x[i].work);
        }
 
-       kfree(pca955x);
        i2c_set_clientdata(client, NULL);
+       kfree(pca955x);
 
        return err;
 }
@@ -356,8 +356,8 @@ static int __devexit pca955x_remove(struct i2c_client 
*client)
                cancel_work_sync(&pca955x[i].work);
        }
 
-       kfree(pca955x);
        i2c_set_clientdata(client, NULL);
+       kfree(pca955x);
 
        return 0;
 }
-- 
1.7.0

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to