driver core/platform_device_add_data: free platform data before overwriting
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Wed, 20 Apr 2011 07:44:43 +0000 (09:44 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Sat, 23 Apr 2011 00:09:12 +0000 (17:09 -0700)
Reviewed-by: Viresh Kumar <viresh.kumar@st.com>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/base/platform.c

index 65cb4c3976030d9ca50485c11a2d0fcff0118bf3..58ad8e8ad7a360c5d8bd17a62fe17579ca943878 100644 (file)
@@ -228,6 +228,7 @@ int platform_device_add_data(struct platform_device *pdev, const void *data,
                        return -ENOMEM;
        }
 
+       kfree(pdev->dev.platform_data);
        pdev->dev.platform_data = d;
        return 0;
 }