From patchwork Tue Feb 25 11:19:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 25278 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f197.google.com (mail-vc0-f197.google.com [209.85.220.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D469820143 for ; Tue, 25 Feb 2014 11:25:23 +0000 (UTC) Received: by mail-vc0-f197.google.com with SMTP id hq11sf14113814vcb.8 for ; Tue, 25 Feb 2014 03:25:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :mime-version:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe:content-type :content-transfer-encoding; bh=Po4zJGeMAxR8AuqBfOzrrtay6lX4/rt+siChCk5T01g=; b=WsC2NmyHB+N6Ku+0t+NHFeYOuBZ68PekLfOzX3Iae3fEU2a0JnfvmWEHF3Wwt8xCV6 XO+gNdPkOEJyX+WdnVifhAFI1UxA77AebE1Pc6YngSWEqSWdsx9u7PQflBMIezPcXKq6 RPlM+X/S8UcHnHKQx0ekYuTGakxOfCrJnmzb81FUXrgsLuTcgPOvwCokOXXuNJKP0yjK A0quRnsbsgZlK/EtDG3uIgfgDcjl1meKd4fyQCVvFxKv9f3yciHHiyvtXBb5kWCsOfZ8 VcdFXi8+zWlnh5ceDhQzszhfOs3T87HLlP/S3R+tjYOV8dF8+UPDQ/g1Mxwix1duDR8S PJRQ== X-Gm-Message-State: ALoCoQmhWIFuML/i6B4aP9gO0ADZJWEIAwxnR8LLGaSCb+ikFb+61/bZtkh/vtyHipo2/UWsjSjg X-Received: by 10.58.182.135 with SMTP id ee7mr429589vec.15.1393327523421; Tue, 25 Feb 2014 03:25:23 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.23.175 with SMTP id 44ls1939201qgp.12.gmail; Tue, 25 Feb 2014 03:25:23 -0800 (PST) X-Received: by 10.220.10.2 with SMTP id n2mr679944vcn.26.1393327523330; Tue, 25 Feb 2014 03:25:23 -0800 (PST) Received: from mail-vc0-f176.google.com (mail-vc0-f176.google.com [209.85.220.176]) by mx.google.com with ESMTPS id w5si6726043vcl.66.2014.02.25.03.25.23 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 25 Feb 2014 03:25:23 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.176 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.176; Received: by mail-vc0-f176.google.com with SMTP id la4so6958449vcb.21 for ; Tue, 25 Feb 2014 03:25:23 -0800 (PST) X-Received: by 10.220.67.18 with SMTP id p18mr696415vci.14.1393327523247; Tue, 25 Feb 2014 03:25:23 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.174.196 with SMTP id u4csp131237vcz; Tue, 25 Feb 2014 03:25:22 -0800 (PST) X-Received: by 10.68.96.99 with SMTP id dr3mr6081215pbb.40.1393327522434; Tue, 25 Feb 2014 03:25:22 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id nd12si20390940pab.40.2014.02.25.03.25.21; Tue, 25 Feb 2014 03:25:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752815AbaBYLZL (ORCPT + 26 others); Tue, 25 Feb 2014 06:25:11 -0500 Received: from mail-pd0-f169.google.com ([209.85.192.169]:42029 "EHLO mail-pd0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751912AbaBYLZJ (ORCPT ); Tue, 25 Feb 2014 06:25:09 -0500 Received: by mail-pd0-f169.google.com with SMTP id v10so7713009pde.28 for ; Tue, 25 Feb 2014 03:25:09 -0800 (PST) X-Received: by 10.66.129.133 with SMTP id nw5mr1103017pab.98.1393327509289; Tue, 25 Feb 2014 03:25:09 -0800 (PST) Received: from linaro.sisodomain.com ([115.113.119.130]) by mx.google.com with ESMTPSA id hc4sm9663227pbc.29.2014.02.25.03.25.05 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 25 Feb 2014 03:25:08 -0800 (PST) From: Sachin Kamat To: linux-kernel@vger.kernel.org Cc: broonie@kernel.org, lgirdwood@gmail.com, philippe.retornaz@epfl.ch, sachin.kamat@linaro.org Subject: [PATCH 1/1] regulator: mc13xxx: Fix NULL pointer error in non-DT mode Date: Tue, 25 Feb 2014 16:49:27 +0530 Message-Id: <1393327167-8526-1-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: sachin.kamat@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.176 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Add a check to avoid NULL pointer dereference error when booted in non-DT mode. While at it also remove the additional of_node_get which is no longer needed for of_get_child_by_name and fix the node pointer. Signed-off-by: Sachin Kamat Reported-by: Philippe Rétornaz --- drivers/regulator/mc13xxx-regulator-core.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/regulator/mc13xxx-regulator-core.c b/drivers/regulator/mc13xxx-regulator-core.c index 4498a3f0733d..bf75fcabfa3c 100644 --- a/drivers/regulator/mc13xxx-regulator-core.c +++ b/drivers/regulator/mc13xxx-regulator-core.c @@ -167,8 +167,10 @@ int mc13xxx_get_num_regulators_dt(struct platform_device *pdev) struct device_node *parent; int num; - of_node_get(pdev->dev.parent->of_node); - parent = of_get_child_by_name(pdev->dev.parent->of_node, "regulators"); + if (!pdev->dev.of_node) + return -ENODEV; + + parent = of_get_child_by_name(pdev->dev.of_node, "regulators"); if (!parent) return -ENODEV; @@ -187,8 +189,10 @@ struct mc13xxx_regulator_init_data *mc13xxx_parse_regulators_dt( struct device_node *parent, *child; int i, parsed = 0; - of_node_get(pdev->dev.parent->of_node); - parent = of_get_child_by_name(pdev->dev.parent->of_node, "regulators"); + if (!pdev->dev.of_node) + return NULL; + + parent = of_get_child_by_name(pdev->dev.of_node, "regulators"); if (!parent) return NULL;