Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753139AbaBXPK3 (ORCPT ); Mon, 24 Feb 2014 10:10:29 -0500 Received: from mail-oa0-f46.google.com ([209.85.219.46]:44711 "EHLO mail-oa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752617AbaBXPK2 convert rfc822-to-8bit (ORCPT ); Mon, 24 Feb 2014 10:10:28 -0500 MIME-Version: 1.0 In-Reply-To: <530B6023.5020400@epfl.ch> References: <530B4CB6.9010608@epfl.ch> <530B6023.5020400@epfl.ch> Date: Mon, 24 Feb 2014 20:40:27 +0530 Message-ID: Subject: Re: [PATCH 13/16] regulator: mc13xxx: Use of_get_child_by_name From: Sachin Kamat To: =?ISO-8859-1?Q?Philippe_R=E9tornaz?= Cc: Mark Brown , LKML , Liam Girdwood Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 24 February 2014 20:37, Philippe R?tornaz wrote: > Le 24/02/2014 15:51, Sachin Kamat a ?crit : > >> On 24 February 2014 19:14, Philippe R?tornaz >> wrote: >>> >>> Hi >>> >>> This patch breaks DT-Enabled kernel run on non-DT board: [ >>> 0.822977] Unable to handle kernel NULL pointer dereference at >>> virtual address 0000001c (...) [ 0.880320] [] >>> (of_get_next_child) from [] >>> (of_get_child_by_name+0x38/0x50) [ 0.881449] [] >>> (of_get_child_by_name) from [] >>> (mc13xxx_get_num_regulators_dt+0x18/0x64) [ 0.882707] >>> [] (mc13xxx_get_num_regulators_dt) from [] >>> (mc13783_regulator_probe+0x34/0x17c) [ 0.884011] [] >>> (mc13783_regulator_probe) from [] >>> (platform_drv_probe+0x20/0x54) [ 0.885182] [] >>> (platform_drv_probe) from [] >>> (driver_probe_device+0x144/0x360) (...) >>> >>> Because mc13783-regulator do in its probe: static int >>> mc13783_regulator_probe(struct platform_device *pdev) { (...) int >>> i, num_regulators; >>> >>> num_regulators = mc13xxx_get_num_regulators_dt(pdev); if >>> (num_regulators <= 0 && pdata) num_regulators = >>> pdata->num_regulators >>> >>> >>> and mc13xxx_get_num_regulators_dt() do, before your patch: >>> >>> parent = of_find_node_by_name(pdev->dev.parent->of_node, >>> "regulators"); if (!parent) return -ENODEV; >>> >>> of_find_node_by_name will return NULL if the node passed is NULL >>> and the DT is non-existant. >>> >>> But, with your change we use this: parent = >>> of_get_child_by_name(pdev->dev.parent->of_node, "regulators"); >>> >>> Which will OOPS as it does not expect to have a NULL node passed as >>> argument. >>> >>> So please revert this patch. >> >> >> Sorry for the issue caused due to this patch. I would prefer to try >> to have this fixed before reverting. Can you please try with below >> change and let me know if it works: >> >> parent = of_get_child_by_name(pdev->dev->of_node, "regulators"); >> > > You meant pdev->dev.of_node here I guess ? Yes right. Sorry for the typo. > This still OOPS as the board is not booting with DT, so all of_node are > NULL. So this is non-DT mode. Please see further comments below. > >> Also, how about adding NULL check to see it the node exists at all? >> > > Could be an option. BTW, mc13xxx_parse_regulators_dt() has the same problem. I would suggest adding a check at the initial stage itself to see if it is non-DT and then either error out or skip appropriately. -- With warm regards, Sachin -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/