lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <508C096B.6060902@gmail.com>
Date:	Sat, 27 Oct 2012 18:18:51 +0200
From:	Francesco Lavra <francescolavra.fl@...il.com>
To:	Rajanikanth HV <rajanikanth.hv@...aro.org>
CC:	"Rajanikanth H.V" <rajanikanth.hv@...ricsson.com>,
	linaro-dev@...ts.linaro.org, linus.walleij@...ricsson.com,
	arnd@...db.de, patches@...aro.org, linux-kernel@...r.kernel.org,
	anton.vorontsov@...aro.org, STEricsson_nomadik_linux@...t.st.com,
	linux-arm-kernel@...ts.infradead.org
Subject: Re: [PATCH 1/4] mfd: ab8500: add devicetree support for fuelgauge

On 10/27/2012 06:00 PM, Rajanikanth HV wrote:
> On 27 October 2012 20:37, Francesco Lavra <francescolavra.fl@...il.com> wrote:
>> On 10/25/2012 08:30 AM, Rajanikanth H.V wrote:
>>> From: "Rajanikanth H.V" <rajanikanth.hv@...ricsson.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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ