All of lore.kernel.org
 help / color / mirror / Atom feed
From: Francesco Lavra <francescolavra.fl@gmail.com>
To: Rajanikanth HV <rajanikanth.hv@linaro.org>
Cc: "Rajanikanth H.V" <rajanikanth.hv@stericsson.com>,
	linaro-dev@lists.linaro.org, linus.walleij@stericsson.com,
	arnd@arndb.de, patches@linaro.org, linux-kernel@vger.kernel.org,
	anton.vorontsov@linaro.org, STEricsson_nomadik_linux@list.st.com,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 1/4] mfd: ab8500: add devicetree support for fuelgauge
Date: Sat, 27 Oct 2012 18:18:51 +0200	[thread overview]
Message-ID: <508C096B.6060902@gmail.com> (raw)
In-Reply-To: <CAB4BAkuPE6eSr2+LWTaV9trOnFk-_yt-+x8f6zpum=Ws1UvmmA@mail.gmail.com>

On 10/27/2012 06:00 PM, Rajanikanth HV wrote:
> On 27 October 2012 20:37, Francesco Lavra <francescolavra.fl@gmail.com> wrote:
>> On 10/25/2012 08:30 AM, Rajanikanth H.V wrote:
>>> From: "Rajanikanth H.V" <rajanikanth.hv@stericsson.com>
>>> +     bat_tech = of_get_property(np_bat_supply,
>>> +                     "stericsson,battery-type", NULL);
>>> +     if (!bat_tech)
>>> +             dev_warn(dev, "missing property battery-name/type\n");
>>> +
>>> +     if (strncmp(bat_tech, "LION", 4) == 0) {
>>
>> What if bat_tech is NULL?
> It will be UNKNOWN

I wanted to draw your attention to the fact that if bat_tech is NULL you
are passing a NULL pointer to strncmp(), which is not good.
So you should assign a default value to bat_tech in case the battery
type property is not found in the DT, as below:

if (!bat_tech) {
	dev_warn(dev, "missing property battery-name/type\n");
	bat_tech = "UNKNOWN";
}

--
Francesco

WARNING: multiple messages have this Message-ID (diff)
From: francescolavra.fl@gmail.com (Francesco Lavra)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/4] mfd: ab8500: add devicetree support for fuelgauge
Date: Sat, 27 Oct 2012 18:18:51 +0200	[thread overview]
Message-ID: <508C096B.6060902@gmail.com> (raw)
In-Reply-To: <CAB4BAkuPE6eSr2+LWTaV9trOnFk-_yt-+x8f6zpum=Ws1UvmmA@mail.gmail.com>

On 10/27/2012 06:00 PM, Rajanikanth HV wrote:
> On 27 October 2012 20:37, Francesco Lavra <francescolavra.fl@gmail.com> wrote:
>> On 10/25/2012 08:30 AM, Rajanikanth H.V wrote:
>>> From: "Rajanikanth H.V" <rajanikanth.hv@stericsson.com>
>>> +     bat_tech = of_get_property(np_bat_supply,
>>> +                     "stericsson,battery-type", NULL);
>>> +     if (!bat_tech)
>>> +             dev_warn(dev, "missing property battery-name/type\n");
>>> +
>>> +     if (strncmp(bat_tech, "LION", 4) == 0) {
>>
>> What if bat_tech is NULL?
> It will be UNKNOWN

I wanted to draw your attention to the fact that if bat_tech is NULL you
are passing a NULL pointer to strncmp(), which is not good.
So you should assign a default value to bat_tech in case the battery
type property is not found in the DT, as below:

if (!bat_tech) {
	dev_warn(dev, "missing property battery-name/type\n");
	bat_tech = "UNKNOWN";
}

--
Francesco

  reply	other threads:[~2012-10-27 16:16 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-25  6:30 [PATCH 0/4] Implement device tree support for ab8500 BM Devices Rajanikanth H.V
2012-10-25  6:30 ` [PATCH 1/4] mfd: ab8500: add devicetree support for fuelgauge Rajanikanth H.V
2012-10-27 15:07   ` Francesco Lavra
2012-10-27 15:07     ` Francesco Lavra
2012-10-27 16:00     ` Rajanikanth HV
2012-10-27 16:00       ` Rajanikanth HV
2012-10-27 16:18       ` Francesco Lavra [this message]
2012-10-27 16:18         ` Francesco Lavra
2012-10-25  6:30 ` [PATCH 2/4] mfd: ab8500: add devicetree support for btemp Rajanikanth H.V
2012-10-27 15:08   ` Francesco Lavra
2012-10-27 15:08     ` Francesco Lavra
2012-10-25  6:30 ` [PATCH 3/4] mfd: ab8500: add devicetree support for charger Rajanikanth H.V
2012-10-27 15:10   ` Francesco Lavra
2012-10-27 15:10     ` Francesco Lavra
2012-10-25  6:30 ` [PATCH 4/4] mfd: ab8500: add devicetree support for chargalg Rajanikanth H.V
2012-10-27 15:11   ` Francesco Lavra
2012-10-27 15:11     ` Francesco Lavra
  -- strict thread matches above, loose matches on Subject: below --
2012-11-22 18:43 [PATCH 0/4] Implement device tree support for ab8500 BM Devices Rajanikanth H.V
2012-11-22 18:43 ` [PATCH 1/4] mfd: ab8500: add devicetree support for fuelgauge Rajanikanth H.V
2012-11-22 18:43   ` Rajanikanth H.V
2012-11-22 20:08   ` Anton Vorontsov
2012-11-22 20:08     ` Anton Vorontsov
2012-11-23  9:50     ` Lee Jones
2012-11-23  9:50       ` Lee Jones
2012-10-31 15:40 [PATCH 0/4] Implement device tree support for ab8500 BM Devices Rajanikanth H.V
2012-10-31 15:40 ` [PATCH 1/4] mfd: ab8500: add devicetree support for fuelgauge Rajanikanth H.V
2012-10-31 15:40   ` Rajanikanth H.V
2012-11-01 15:15   ` Francesco Lavra
2012-11-01 15:15     ` Francesco Lavra
2012-11-07 18:45     ` Rajanikanth H V
2012-11-07 18:45       ` Rajanikanth H V
2012-11-10 16:53       ` Francesco Lavra
2012-11-10 16:53         ` Francesco Lavra
2012-11-15 11:34         ` Rajanikanth HV
2012-11-15 11:34           ` Rajanikanth HV
2012-10-01  4:08 [PATCH 0/4] Implement device tree support for ab8500 BM Devices Rajanikanth H.V
2012-10-01  4:08 ` [PATCH 1/4] mfd: ab8500: add devicetree support for fuelgauge Rajanikanth H.V
2012-10-01  9:49   ` Lee Jones
2012-10-01  9:49     ` Lee Jones
2012-10-01  9:59     ` Rajanikanth HV
2012-10-01  9:59       ` Rajanikanth HV
2012-10-01 10:36       ` Lee Jones
2012-10-01 10:36         ` Lee Jones
2012-10-01 10:22     ` Lee Jones
2012-10-01 10:22       ` Lee Jones
2012-10-06 14:01   ` Francesco Lavra
2012-10-06 14:01     ` Francesco Lavra

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=508C096B.6060902@gmail.com \
    --to=francescolavra.fl@gmail.com \
    --cc=STEricsson_nomadik_linux@list.st.com \
    --cc=anton.vorontsov@linaro.org \
    --cc=arnd@arndb.de \
    --cc=linaro-dev@lists.linaro.org \
    --cc=linus.walleij@stericsson.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=patches@linaro.org \
    --cc=rajanikanth.hv@linaro.org \
    --cc=rajanikanth.hv@stericsson.com \
    /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.