From patchwork Thu Sep 4 12:01:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 36689 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oi0-f70.google.com (mail-oi0-f70.google.com [209.85.218.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 680BF202E4 for ; Thu, 4 Sep 2014 12:02:33 +0000 (UTC) Received: by mail-oi0-f70.google.com with SMTP id u20sf47869212oif.5 for ; Thu, 04 Sep 2014 05:02:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:in-reply-to:references :sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=ppveiJFswB4iZvh2dUINDcQgkCj/isZqmLqqJAKThG8=; b=c2N3gcCJUvqrf34tKoztCW7yd0n1FVS6C5ez7Gm4sV/BhtziKoA9IYdy3khF3R/Dcl hNC8M08zgelruvmZnNEAv0N2PuVvSj0/OdN7ITb7bGS3USgGMO8Wj1DLBZzzkfK6dnA2 GFVPW+AFjOMRSHSq0Y/KkPGCNS8QYe4HegDNP22y6/p5hVV1necKzMixLRxshsZLoj6+ ITZrS7aroYWpaDR4dDnEeuAu1Hn9AQbRgRmaJlPRDFh8ekCwaRV1jGBK8uGJYg7GHObb JZMBn8/sLB8ALsnPHvfQE8/JevljiGsqC6GF37AHxBRutGLIhRC53caxiylk98/NTGKx t1bA== X-Gm-Message-State: ALoCoQlDZp+Se4S3JECt/X6hehBKFxgVzqwx4iYX2mVR7UDhCSNwYi7IMQL2YiVVXXsU9XHL223c X-Received: by 10.42.133.200 with SMTP id i8mr2062265ict.14.1409832152823; Thu, 04 Sep 2014 05:02:32 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.42.87 with SMTP id b81ls239120qga.19.gmail; Thu, 04 Sep 2014 05:02:32 -0700 (PDT) X-Received: by 10.52.4.69 with SMTP id i5mr2547811vdi.35.1409832152640; Thu, 04 Sep 2014 05:02:32 -0700 (PDT) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id rx9si2705071vdb.71.2014.09.04.05.02.32 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 04 Sep 2014 05:02:32 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.178 as permitted sender) client-ip=209.85.220.178; Received: by mail-vc0-f178.google.com with SMTP id la4so10639036vcb.9 for ; Thu, 04 Sep 2014 05:02:32 -0700 (PDT) X-Received: by 10.52.120.51 with SMTP id kz19mr291589vdb.95.1409832152463; Thu, 04 Sep 2014 05:02:32 -0700 (PDT) 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.221.45.67 with SMTP id uj3csp824238vcb; Thu, 4 Sep 2014 05:02:31 -0700 (PDT) X-Received: by 10.66.66.163 with SMTP id g3mr7738082pat.150.1409832150975; Thu, 04 Sep 2014 05:02:30 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id lp3si3076549pab.230.2014.09.04.05.02.25 for ; Thu, 04 Sep 2014 05:02:26 -0700 (PDT) Received-SPF: none (google.com: linux-pm-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753883AbaIDMCL (ORCPT + 15 others); Thu, 4 Sep 2014 08:02:11 -0400 Received: from mail-pd0-f181.google.com ([209.85.192.181]:41288 "EHLO mail-pd0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753777AbaIDMCK (ORCPT ); Thu, 4 Sep 2014 08:02:10 -0400 Received: by mail-pd0-f181.google.com with SMTP id fp1so13552409pdb.40 for ; Thu, 04 Sep 2014 05:02:10 -0700 (PDT) X-Received: by 10.67.23.70 with SMTP id hy6mr8177209pad.30.1409832129025; Thu, 04 Sep 2014 05:02:09 -0700 (PDT) Received: from localhost ([122.167.123.172]) by mx.google.com with ESMTPSA id ou6sm1509972pbb.88.2014.09.04.05.02.07 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 04 Sep 2014 05:02:08 -0700 (PDT) From: Viresh Kumar To: sre@kernel.org, dbaryshkov@gmail.com, dwmw2@infradead.org, anton@enomsg.org Cc: linux-pm@vger.kernel.org, linaro-kernel@lists.linaro.org, Viresh Kumar Subject: [PATCH 02/15] power-supply: Return early if "power-supplies" property isn't valid Date: Thu, 4 Sep 2014 17:31:23 +0530 Message-Id: X-Mailer: git-send-email 2.0.3.693.g996b0fd In-Reply-To: <2eacd908a8094887cc1796f75ae0513be8a3e36d.1409831636.git.viresh.kumar@linaro.org> References: <2eacd908a8094887cc1796f75ae0513be8a3e36d.1409831636.git.viresh.kumar@linaro.org> In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.178 as permitted sender) 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: , If power-supply's DT node doesn't have a valid "power-supplies" entry, then power_supply_check_supplies() should return early instead of trying to allocate memory for "supplied_from" array. Signed-off-by: Viresh Kumar --- drivers/power/power_supply_core.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c index 10f0b57..414384a 100644 --- a/drivers/power/power_supply_core.c +++ b/drivers/power/power_supply_core.c @@ -226,6 +226,10 @@ static int power_supply_check_supplies(struct power_supply *psy) of_node_put(np); } while (np); + /* Missing valid "power-supplies" entries */ + if (cnt == 1) + return 0; + /* All supplies found, allocate char ** array for filling */ psy->supplied_from = devm_kzalloc(psy->dev, sizeof(psy->supplied_from), GFP_KERNEL);