From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754983AbbAGRbc (ORCPT ); Wed, 7 Jan 2015 12:31:32 -0500 Received: from comal.ext.ti.com ([198.47.26.152]:60428 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754391AbbAGRb1 (ORCPT ); Wed, 7 Jan 2015 12:31:27 -0500 From: Suman Anna To: Grant Likely , Rob Herring CC: Greg Kroah-Hartman , Pawel Moll , Pantelis Antoniou , Felipe Balbi , , , , , Suman Anna Subject: [RFC PATCH 2/3] core: platform: fix an invalid kfree during of_platform_depopulate Date: Wed, 7 Jan 2015 11:30:53 -0600 Message-ID: <1420651854-17768-3-git-send-email-s-anna@ti.com> X-Mailer: git-send-email 2.2.1 In-Reply-To: <1420651854-17768-1-git-send-email-s-anna@ti.com> References: <1420651854-17768-1-git-send-email-s-anna@ti.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Drivers can use of_platform_populate() to create platform devices for children of the device main node, and a complementary API of_platform_depopulate() is provided to delete these child devices. Any platform_data supplied for the OF devices through auxdata lookup data is populated directly in the device's platform_data field, unlike those created using platform API. The of_platform_depopulate() leverages the platform code for cleanup, and this will result in a kernel oops due to an invalid kfree on this direct populated platform_data. Fix this by resetting the platform data for OF devices during platform device cleanup. Signed-off-by: Suman Anna --- drivers/base/platform.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 9421fed40905..129e69c8c894 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -200,6 +200,8 @@ static void platform_device_release(struct device *dev) struct platform_object *pa = container_of(dev, struct platform_object, pdev.dev); + if (pa->pdev.dev.of_node) + pa->pdev.dev.platform_data = NULL; of_device_node_put(&pa->pdev.dev); kfree(pa->pdev.dev.platform_data); kfree(pa->pdev.mfd_cell); -- 2.2.1