From: Guenter Roeck <linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
To: Pantelis Antoniou
<pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>,
Ioan Nicu <ioan.nicu.ext-OYasijW0DpE@public.gmane.org>
Cc: Alexander Sverdlin
<alexander.sverdlin-OYasijW0DpE@public.gmane.org>,
Grant Likely
<grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>,
Rob Herring <robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Stephen Warren <swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>,
Matt Porter <matt.porter-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
Koen Kooi
<koen-QLwJDigV5abLmq1fohREcCpxlwaOVQ5f@public.gmane.org>,
Greg Kroah-Hartman
<gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>,
Alison Chaiken
<Alison_Chaiken-nmGgyN9QBj3QT0dZR+AlfA@public.gmane.org>,
Dinh Nguyen <dinh.linux-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Jan Lubbe <jluebbe-H4yykcOXDpCzQB+pC5nmwQ@public.gmane.org>,
Michael Stickel <ms-g5CePrrZ5ROELgA04lAiVw@public.gmane.org>,
Dirk Behme <dirk.behme-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Alan Tull
<delicious.quinoa-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>,
Michael Bohan <mbohan-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>,
Michal Simek <monstr-pSz03upnqPeHXe+LvDLADg@public.gmane.org>,
Matt Ranostay <mranostay-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Joel Becker <jlbec-aKy9MeLSZ9dg9hUCZPvPmw@public.gmane.org>,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>,
linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.orgPe
Subject: Re: [PATCH 5/6] OF: Utility helper functions for dynamic nodes
Date: Mon, 23 Jun 2014 12:48:26 -0700 [thread overview]
Message-ID: <53A8848A.3000803@roeck-us.net> (raw)
In-Reply-To: <78ACBAF6-A73E-4272-8D3A-258C4B10858C-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
On 06/23/2014 12:13 PM, Pantelis Antoniou wrote:
> Hi Ioan,
>
> I'm going to let Grant answer that but the code in question doesn't look right.
>
> On Jun 23, 2014, at 9:33 PM, Ioan Nicu wrote:
>
>> Hi Pantelis,
>>
>> On Mon, Jun 23, 2014 at 07:57:24PM +0300, ext Pantelis Antoniou wrote:
>>> Hi Alexander,
>>>
>>> On Jun 23, 2014, at 7:26 PM, Alexander Sverdlin wrote:
>>>
>>>> Hello Pantelis!
>>>>
>>>> On 22/06/14 11:40, ext Pantelis Antoniou wrote:
>>>>> Introduce helper functions for working with the live DT tree,
>>>>> all of them related to dynamically adding/removing nodes and
>>>>> properties.
>>>>>
>>>>> __of_copy_property() copies a property dynamically
>>>>> __of_create_empty_node() creates an empty node
>>>>>
>>>>> Bug fix about prop->len == 0 by Ionut Nicu <ioan.nicu.ext-OYasijW0DpE@public.gmane.org>
>>>>
>>>> Are you sure about this? (see below...)
>>>>
>>
>> Alexander is right, my fix was lost even though it's mentioned in this patch.
>>
>
> I'm sorry, I didn't understand that the intention of the fix was to address
> the issue below.
>
>>>>> Signed-off-by: Pantelis Antoniou <pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
>>>>> ---
>>>
>>> [snip]
>>>>> +
>>>>> + if (prop->length > 0) {
>>>> ^^^^^^^^^^^^^^^^^^^^^
>>>> Seems, that length==0 case will still produce value==NULL results,
>>>> which will brake some checks in the kernel... Or am I missing something in
>>>> the new version?
>>>>
>>>
>>> prop->value will be set to NULL, and length will be set to zero (kzalloc).
>>> This is a normal zero length property.
>>>
>>> I don't know of any place in the kernel accessing the value if prop->length==0
>>>
>>
>> We have a simple use case. We have an overlay which adds an interrupt controller.
>> If you look in drivers/of/irq.c, in of_irq_parse_raw():
>>
>> [...]
>> /* Now start the actual "proper" walk of the interrupt tree */
>> while (ipar != NULL) {
>> /* Now check if cursor is an interrupt-controller and if it is
>> * then we are done
>> */
>> if (of_get_property(ipar, "interrupt-controller", NULL) !=
>> NULL) {
>> pr_debug(" -> got it !\n");
>> return 0;
>> }
>> [...]
>>
>> A node is identified as an interrupt controller if it has a zero-length property
>> called "interrupt-controller" but with a non-NULL value.
>>
>> My proposed fix for this was to remove the if () condition. propn->value will be
>> allocated with kmalloc(0) which returns ZERO_SIZE_PTR which is != NULL.
>>
>
> If that's the case, the code in irq.c is wrong.
>
> interrupt-controller is a bool property; the correct call to use is of_property_read_bool()
> which returns true or false when the value is defined.
>
> The use of of_get_property is a bug here. It is perfectly valid for a property to have a
> NULL value when length = 0.
>
That usage is spread throughout the code though. There are three or four similar checks
for interrupt-controller in the code, and many others using of_get_property() to check
for booleans.
Some examples:
s5m8767,pmic-buck2-ramp-enable
s5m8767,pmic-buck3-ramp-enable
s5m8767,pmic-buck4-ramp-enable
d7s-flipped?
atmel,use-dma-rx
linux,rs485-enabled-at-boot-time
marvell,enable-port1 (and many others)
linux,bootx-noscreen
linux,opened
and many many others.
Maybe people meant to use of_find_property() ?
Either case, if the new code depends on proper use of of_get_property(), we may have
a problem unless all those bad use cases are fixed.
Guenter
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2014-06-23 19:48 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-22 9:40 [PATCH 0/6] OF: Fixes preparing transactions/overlays Pantelis Antoniou
2014-06-22 9:40 ` [PATCH 1/6] of: Do not free memory at of_node_release Pantelis Antoniou
2014-06-24 14:10 ` Grant Likely
2014-06-24 14:23 ` Pantelis Antoniou
2014-06-24 20:21 ` Grant Likely
2014-06-24 20:23 ` Pantelis Antoniou
2014-06-24 20:33 ` Guenter Roeck
2014-06-24 21:02 ` Pantelis Antoniou
2014-06-24 23:20 ` Guenter Roeck
2014-06-25 19:24 ` Grant Likely
2014-06-24 14:53 ` Guenter Roeck
2014-06-22 9:40 ` [PATCH 2/6] OF: Add [__]of_find_node_by_full_name Pantelis Antoniou
2014-06-23 17:58 ` Guenter Roeck
2014-06-23 18:00 ` Pantelis Antoniou
[not found] ` <4F4A55EC-744B-49CC-96FA-811C9483A43D-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
2014-06-24 13:55 ` Grant Likely
2014-06-24 14:12 ` Grant Likely
2014-06-24 14:23 ` Pantelis Antoniou
2014-06-22 9:40 ` [PATCH 3/6] of: platform: Fix and export of_platform_device_destroy Pantelis Antoniou
2014-06-24 14:23 ` Grant Likely
2014-06-24 15:13 ` Grant Likely
2014-06-22 9:40 ` [PATCH 4/6] OF: Export a number of __of_* methods Pantelis Antoniou
2014-06-24 19:27 ` Grant Likely
2014-06-24 19:38 ` Pantelis Antoniou
2014-06-24 20:19 ` Grant Likely
2014-06-22 9:40 ` [PATCH 5/6] OF: Utility helper functions for dynamic nodes Pantelis Antoniou
[not found] ` <1403430039-15085-6-git-send-email-pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
2014-06-23 16:26 ` Alexander Sverdlin
2014-06-23 16:57 ` Pantelis Antoniou
2014-06-23 18:33 ` Ioan Nicu
2014-06-23 19:13 ` Pantelis Antoniou
[not found] ` <78ACBAF6-A73E-4272-8D3A-258C4B10858C-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
2014-06-23 19:48 ` Guenter Roeck [this message]
2014-06-23 20:39 ` Ioan Nicu
2014-06-24 9:08 ` Pantelis Antoniou
2014-06-24 13:46 ` Rob Herring
2014-06-24 13:53 ` Alexander Sverdlin
2014-06-24 14:49 ` Rob Herring
2014-06-24 15:43 ` Alexander Sverdlin
2014-06-24 15:59 ` Pantelis Antoniou
2014-06-24 18:23 ` Ioan Nicu
2014-06-24 18:31 ` Ioan Nicu
2014-06-24 18:43 ` Pantelis Antoniou
2014-06-24 8:12 ` Alexander Sverdlin
2014-06-24 8:19 ` Pantelis Antoniou
2014-06-24 8:38 ` Alexander Sverdlin
2014-06-24 8:54 ` Pantelis Antoniou
2014-06-24 9:00 ` Alexander Sverdlin
2014-06-24 9:09 ` Pantelis Antoniou
2014-06-24 8:10 ` Alexander Sverdlin
2014-06-25 9:09 ` Grant Likely
2014-06-25 11:14 ` Grant Likely
2014-06-25 11:22 ` Pantelis Antoniou
2014-06-22 9:40 ` [PATCH 6/6] of: Introduce tree change __foo_post methods Pantelis Antoniou
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=53A8848A.3000803@roeck-us.net \
--to=linux-0h96xk9xttrk1umjsbkqmq@public.gmane.org \
--cc=Alison_Chaiken-nmGgyN9QBj3QT0dZR+AlfA@public.gmane.org \
--cc=alexander.sverdlin-OYasijW0DpE@public.gmane.org \
--cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=delicious.quinoa-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=dinh.linux-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=dirk.behme-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org \
--cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
--cc=ioan.nicu.ext-OYasijW0DpE@public.gmane.org \
--cc=jlbec-aKy9MeLSZ9dg9hUCZPvPmw@public.gmane.org \
--cc=jluebbe-H4yykcOXDpCzQB+pC5nmwQ@public.gmane.org \
--cc=koen-QLwJDigV5abLmq1fohREcCpxlwaOVQ5f@public.gmane.org \
--cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.orgPe \
--cc=linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=matt.porter-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=mbohan-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
--cc=monstr-pSz03upnqPeHXe+LvDLADg@public.gmane.org \
--cc=mranostay-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=ms-g5CePrrZ5ROELgA04lAiVw@public.gmane.org \
--cc=pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org \
--cc=robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org \
--cc=swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org \
--cc=wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).