From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758125AbbCDDvv (ORCPT ); Tue, 3 Mar 2015 22:51:51 -0500 Received: from mail-we0-f180.google.com ([74.125.82.180]:33801 "EHLO mail-we0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757466AbbCDDvt (ORCPT ); Tue, 3 Mar 2015 22:51:49 -0500 Message-ID: <54F681A2.9020803@gmail.com> Date: Wed, 04 Mar 2015 04:53:06 +0100 From: Ingo Flaschberger User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: linux-kernel@vger.kernel.org Subject: unbind/bind w1-gpio with device tree produce a crash Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If w1-gpio is probed via device-tree configuration, pdata is allocated via devm_kzalloc. When the device is unbind (and bind later) the allocated memory of pdate is freed - but it will not be allocacted again. static int w1_gpio_probe(struct platform_device *pdev) struct w1_bus_master *master; struct w1_gpio_platform_data *pdata = pdev->dev.platform_data; int err; if(pdata == NULL) { if (of_have_populated_dt()) { err = w1_gpio_probe_dt(pdev); if (err < 0) return err; } } How to detect if pdata was allocated via device-tree devm_kzalloc and not "hardcoded"? Then I could set pdev->dev.platform_data to NULL in w1_gpio_remove which will solve the crash. Kind regards, Ingo Flascherger