From patchwork Wed Jan 7 17:30:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suman Anna X-Patchwork-Id: 5586141 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 73AD5BF6C3 for ; Wed, 7 Jan 2015 17:32:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AA4DF202A1 for ; Wed, 7 Jan 2015 17:32:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C43722027D for ; Wed, 7 Jan 2015 17:32:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754956AbbAGRbb (ORCPT ); Wed, 7 Jan 2015 12:31:31 -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 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id t07HUuiX011934; Wed, 7 Jan 2015 11:30:56 -0600 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id t07HUugU032550; Wed, 7 Jan 2015 11:30:56 -0600 Received: from dlep32.itg.ti.com (157.170.170.100) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.3.174.1; Wed, 7 Jan 2015 11:30:55 -0600 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id t07HUt4Q022291; Wed, 7 Jan 2015 11:30:55 -0600 Received: from localhost (irmo.am.dhcp.ti.com [128.247.71.175]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id t07HUtt10077; Wed, 7 Jan 2015 11:30:55 -0600 (CST) 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 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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);