All of lore.kernel.org
 help / color / mirror / Atom feed
From: Linus Walleij <linus.walleij@stericsson.com>
To: Anton Vorontsov <anton.vorontsov@linaro.org>,
	<linux-kernel@vger.kernel.org>
Cc: Karl Komierowski <karl.komierowski@stericsson.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Arun Murthy <arun.murthy@stericsson.com>
Subject: [PATCH 1/3] power/ab8500_charger: harden platform data check
Date: Fri, 13 Apr 2012 10:15:49 +0200	[thread overview]
Message-ID: <1334304949-18301-1-git-send-email-linus.walleij@stericsson.com> (raw)

From: Linus Walleij <linus.walleij@linaro.org>

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 <arun.murthy@stericsson.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 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;
-- 
1.7.9.2


             reply	other threads:[~2012-04-13  8:16 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-13  8:15 Linus Walleij [this message]
2012-04-13  8:42 ` [PATCH 1/3] power/ab8500_charger: harden platform data check Arun MURTHY
2012-05-05 12:06   ` Anton Vorontsov
2012-04-28 12:59 ` Linus Walleij
2012-04-28 16:38   ` Lee Jones
2012-05-05 12:08     ` Anton Vorontsov
     [not found]       ` <CAF2Aj3hy3KOsH3aiZ0UpuERSwOoqFdYQ4su-hEVcU-qp8r5d9A@mail.gmail.com>
2012-05-05 21:55         ` Anton Vorontsov
2012-05-06  7:25           ` Lee Jones
2012-05-22 11:34       ` Lee Jones
2012-05-22 11:56         ` Anton Vorontsov
2012-05-22 12:03           ` Lee Jones
2012-05-22 13:22             ` Anton Vorontsov
2012-05-23 19:00           ` Linus Walleij
2012-05-02 11:31   ` Lee Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1334304949-18301-1-git-send-email-linus.walleij@stericsson.com \
    --to=linus.walleij@stericsson.com \
    --cc=anton.vorontsov@linaro.org \
    --cc=arun.murthy@stericsson.com \
    --cc=karl.komierowski@stericsson.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.