From patchwork Fri Apr 13 08:16:13 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 7774 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 710B823E4D for ; Fri, 13 Apr 2012 08:16:22 +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 3B0DFA183DF for ; Fri, 13 Apr 2012 08:16:22 +0000 (UTC) Received: by mail-iy0-f180.google.com with SMTP id e36so5379950iag.11 for ; Fri, 13 Apr 2012 01:16:22 -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=e7QOU8+njfyQzrqhhrZirZ9PC2Y7P0KKCnflRikIISA=; b=IW6JbI4KQSmY6eEjL1hngYEA5xcMQI+EHSKz1W5bLzqWIM1DJn3Z/M8HvPb083Q7Hj m7hWjmWyl4MEVAazTOAH7OInAjbdzW9FItShdeevohN4Rp+4gcmb4X29XASkTsQHZ/Ro 2WRwJyjpnN/Npg4OvlAiSmfSsVXdZWloE237Cv+CJCadPlYTMbdKOCLp44IL7n4i4ljB J2fU9wpXEJX1RzCkkB06xYbH9aypmC1ZtWQbPVPVjq4LD8G0LcGRUiiBEBiPuV3MhA0Z Gu2Nw0Nek82uwFmFD4CtO6oJl6+W2lCLxHtp6BqgT8/OgKwgc4sQ5+G+ZbmvNDgVQRpj FIZA== Received: by 10.50.158.202 with SMTP id ww10mr697626igb.30.1334304982019; Fri, 13 Apr 2012 01:16:22 -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 c5csp13102ibj; Fri, 13 Apr 2012 01:16:21 -0700 (PDT) Received: by 10.14.39.195 with SMTP id d43mr91234eeb.28.1334304980784; Fri, 13 Apr 2012 01:16:20 -0700 (PDT) Received: from eu1sys200aog114.obsmtp.com (eu1sys200aog114.obsmtp.com. [207.126.144.137]) by mx.google.com with SMTP id m55si2396048eeh.32.2012.04.13.01.16.17 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 13 Apr 2012 01:16:20 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.137 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) client-ip=207.126.144.137; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.137 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-eu.st.com ([164.129.1.35]) (using TLSv1) by eu1sys200aob114.postini.com ([207.126.147.11]) with SMTP ID DSNKT4fg0U1MwEgfOl9B15A3bfDCcgdVCFfd@postini.com; Fri, 13 Apr 2012 08:16:19 UTC Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id C0370E8; Fri, 13 Apr 2012 08:16:16 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 4CE4524FA; Fri, 13 Apr 2012 08:16:16 +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 relay1.stm.gmessaging.net (Postfix) with ESMTPS id 321F124C2C0; Fri, 13 Apr 2012 10:16:11 +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:15 +0200 From: Linus Walleij To: Anton Vorontsov , Cc: Karl Komierowski , Linus Walleij , Arun Murthy Subject: [PATCH 3/3] power/ab8500_fg: harden platform data check Date: Fri, 13 Apr 2012 10:16:13 +0200 Message-ID: <1334304973-18378-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: ALoCoQk3FvC24Zql0zwDTvRNqpOvzzktoj7nlQfZ36ExbwiMaplSuRlncvNej6luEi2cLuRgbPQD 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_fg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/power/ab8500_fg.c b/drivers/power/ab8500_fg.c index c22f2f0..0ebea39 100644 --- a/drivers/power/ab8500_fg.c +++ b/drivers/power/ab8500_fg.c @@ -2462,12 +2462,12 @@ static int __devinit ab8500_fg_probe(struct platform_device *pdev) /* get fg specific platform data */ plat_data = pdev->dev.platform_data; - di->pdata = plat_data->fg; - if (!di->pdata) { + if (!plat_data || !plat_data->fg) { dev_err(di->dev, "no fg platform data supplied\n"); ret = -EINVAL; goto free_device_info; } + di->pdata = plat_data->fg; /* get battery specific platform data */ di->bat = plat_data->battery;