From patchwork Fri Apr 13 08:15:49 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 7772 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id A632F23E4D for ; Fri, 13 Apr 2012 08:16:15 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 4B5D5A189ED for ; Fri, 13 Apr 2012 08:16:15 +0000 (UTC) Received: by iage36 with SMTP id e36so5379950iag.11 for ; Fri, 13 Apr 2012 01:16:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:mime-version:content-type :x-gm-message-state; bh=M0e/yE6kAOEirgTgPQiPVb9UE7YtxCTcouENIJ07qwY=; b=Fqp4VxtoTD6rY5A249gh0ucchUZhc9dP8Gd0MQ1cJZcetVoHCigD7RayEI0N3wwJJj kp442MfiprQcHN+9YjWx6rVgbS3THJhbBn0Z6FZrRABPfDVFhNkG3CrGPLYaLNnTSeuv x6h9HpF3EviEoJpihxAJBdWZt3VIxNu1iZYTePYc00pA76tFPooDlwh9OclrzQOzYjJd Db6aApsEH2bEdTyYZ1UfyqK3IdFJNqffkaDKfR00xgWNNLoxtm8G121LL3AJZbMFfrwF EGySVEBb215U7QnJDEwTDphGJTPzi3GlwmzCc9UHqrLvpSeA+mvq6BxxIZSiD0WntSQ0 syWg== Received: by 10.50.202.38 with SMTP id kf6mr615636igc.30.1334304974619; Fri, 13 Apr 2012 01:16:14 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.70.69 with SMTP id c5csp13094ibj; Fri, 13 Apr 2012 01:16:13 -0700 (PDT) Received: by 10.14.53.10 with SMTP id f10mr85270eec.65.1334304972101; Fri, 13 Apr 2012 01:16:12 -0700 (PDT) Received: from eu1sys200aog102.obsmtp.com (eu1sys200aog102.obsmtp.com. [207.126.144.113]) by mx.google.com with SMTP id a45si2381977eeg.162.2012.04.13.01.16.06 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 13 Apr 2012 01:16:12 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.113 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) client-ip=207.126.144.113; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.113 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) smtp.mail=linus.walleij@stericsson.com Received: from beta.dmz-ap.st.com ([138.198.100.35]) (using TLSv1) by eu1sys200aob102.postini.com ([207.126.147.11]) with SMTP ID DSNKT4fgxa7nTHmmytFN0Da4cb6wyObgCnRu@postini.com; Fri, 13 Apr 2012 08:16:11 UTC Received: from zeta.dmz-ap.st.com (ns6.st.com [138.198.234.13]) by beta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 8204CDD; Fri, 13 Apr 2012 08:07:39 +0000 (GMT) Received: from relay2.stm.gmessaging.net (unknown [10.230.100.18]) by zeta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 651701870; Fri, 13 Apr 2012 08:16:02 +0000 (GMT) Received: from exdcvycastm004.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm004", Issuer "exdcvycastm004" (not verified)) by relay2.stm.gmessaging.net (Postfix) with ESMTPS id F1283A8065; Fri, 13 Apr 2012 10:15:57 +0200 (CEST) Received: from steludxu4075.lud.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.2) with Microsoft SMTP Server (TLS) id 8.3.83.0; Fri, 13 Apr 2012 10:16:01 +0200 From: Linus Walleij To: Anton Vorontsov , Cc: Karl Komierowski , Linus Walleij , Arun Murthy Subject: [PATCH 1/3] power/ab8500_charger: harden platform data check Date: Fri, 13 Apr 2012 10:15:49 +0200 Message-ID: <1334304949-18301-1-git-send-email-linus.walleij@stericsson.com> X-Mailer: git-send-email 1.7.9.2 MIME-Version: 1.0 X-Gm-Message-State: ALoCoQlhKDszToh1B+IKR7Q0UOlpwAsRzR/3auVvs6oB5sn7Dw78rNmS6ON9oq6PWCoWis9NFJHm From: Linus Walleij If no platform data at all is supplied the driver crashes, extend the checks to be more careful so we can compile in the driver and boot also without platform data present. Cc: Arun Murthy Signed-off-by: Linus Walleij --- drivers/power/ab8500_charger.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/power/ab8500_charger.c b/drivers/power/ab8500_charger.c index e2b4acc..79dc584 100644 --- a/drivers/power/ab8500_charger.c +++ b/drivers/power/ab8500_charger.c @@ -2551,13 +2551,12 @@ static int __devinit ab8500_charger_probe(struct platform_device *pdev) /* get charger specific platform data */ plat_data = pdev->dev.platform_data; - di->pdata = plat_data->charger; - - if (!di->pdata) { + if (!plat_data || !plat_data->charger) { dev_err(di->dev, "no charger platform data supplied\n"); ret = -EINVAL; goto free_device_info; } + di->pdata = plat_data->charger; /* get battery specific platform data */ di->bat = plat_data->battery;