From patchwork Fri Apr 13 08:16:06 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 7773 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 0B44E23E4D for ; Fri, 13 Apr 2012 08:16:17 +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 C8B88A189ED for ; Fri, 13 Apr 2012 08:16:16 +0000 (UTC) Received: by mail-iy0-f180.google.com with SMTP id e36so5379950iag.11 for ; Fri, 13 Apr 2012 01:16:16 -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=sZUVq/wbSghZ0nvPq3FudWw00A8WKwsP+YuiK0YyXWQ=; b=djtUs86duCfB6D9JQV7dXNoUJbrKXumQKcJgXTU9JlaV1T5MHI0SPmJvjgNf7bJVjy KsDUFNuU4XT9UYZD5en7C9f87PFbOUwdQyG2S1ELKEOcS0Ak079EBThWeCkhDHONwB+G fx4kQ46MDgg1CeOQHT8HkcnD1gtIufJeJOq76hK6wd+zSs20RCTau2La02Gw8AxLhjbp J23QsigIJANtANYU1EwSTupSO8z+XrY/a43dV715J7okFoH+Vx0WKAv8Oms3fejZ327r EK6UzuHdbgC+Ev7wQ4vZiIhfhH6pWHGNeNWccpR3Bs0SdAxhuMDFQhXW0VNzQ/xUmDKG 5lxA== Received: by 10.50.189.232 with SMTP id gl8mr610950igc.50.1334304976586; Fri, 13 Apr 2012 01:16:16 -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 c5csp13096ibj; Fri, 13 Apr 2012 01:16:16 -0700 (PDT) Received: by 10.213.96.78 with SMTP id g14mr64235ebn.70.1334304975243; Fri, 13 Apr 2012 01:16:15 -0700 (PDT) Received: from eu1sys200aog105.obsmtp.com (eu1sys200aog105.obsmtp.com. [207.126.144.119]) by mx.google.com with SMTP id s55si2383607eeh.148.2012.04.13.01.16.13 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 13 Apr 2012 01:16:15 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.119 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) client-ip=207.126.144.119; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.119 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 eu1sys200aob105.postini.com ([207.126.147.11]) with SMTP ID DSNKT4fgzBvjSwR3mhZrRVpQAv/p+RLyPnRj@postini.com; Fri, 13 Apr 2012 08:16:15 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 37AA6106; Fri, 13 Apr 2012 08:16:10 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id B35F9261C; Fri, 13 Apr 2012 08:16:09 +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 A299724C2F1; Fri, 13 Apr 2012 10:16:04 +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:09 +0200 From: Linus Walleij To: Anton Vorontsov , Cc: Karl Komierowski , Linus Walleij , Arun Murthy Subject: [PATCH 2/3] power/ab8500_btemp: harden platform data check Date: Fri, 13 Apr 2012 10:16:06 +0200 Message-ID: <1334304966-18342-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: ALoCoQkIZTdMnAiFGnNKMAKUab+Go4sfGipqYeDSujRswNGlC8NQmtoggPBWBGMUTxfZCt+ReFsg 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_btemp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/power/ab8500_btemp.c b/drivers/power/ab8500_btemp.c index d8bb993..e266f03 100644 --- a/drivers/power/ab8500_btemp.c +++ b/drivers/power/ab8500_btemp.c @@ -978,12 +978,12 @@ static int __devinit ab8500_btemp_probe(struct platform_device *pdev) /* get btemp specific platform data */ plat_data = pdev->dev.platform_data; - di->pdata = plat_data->btemp; - if (!di->pdata) { + if (!plat_data || !plat_data->btemp) { dev_err(di->dev, "no btemp platform data supplied\n"); ret = -EINVAL; goto free_device_info; } + di->pdata = plat_data->btemp; /* get battery specific platform data */ di->bat = plat_data->battery;