]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commit
mtd: partitions: fix unbalanced of_node_get/put()
authorMiquel Raynal <miquel.raynal@bootlin.com>
Fri, 7 Sep 2018 14:35:54 +0000 (16:35 +0200)
committerBoris Brezillon <boris.brezillon@bootlin.com>
Mon, 17 Sep 2018 14:23:12 +0000 (16:23 +0200)
commit85516a9881a31e2c7a8d10f4697f3adcccc7cef1
tree99792a8113d8f0e49ca23caa0be5991d07de055c
parentcf51e4b9c34407bf0c3d9b582b7837e047e1df47
mtd: partitions: fix unbalanced of_node_get/put()

While at first mtd_part_of_parse() would just call
of_get_chil_by_name(), it has been patched to deal with sub-partitions
and will now directly manipulate the node returned by mtd_get_of_node()
if the MTD device is a partition.

A of_node_put() was a bit below in the code, to balance the
of_get_child_by_name(). However, despite its name, mtd_get_of_node()
does not take a reference on the OF node. It is a simple helper hiding
some pointer logic to retrieve the OF node related to an MTD
device.

The direct effect of such unbalanced reference counting is visible by
rmmod'ing any module that would have added MTD partitions:

    OF: ERROR: Bad of_node_put() on <of_path_to_partition>

As it seems normal to get a reference on the OF node during the
of_property_for_each_string() that follows, add a call to
of_node_get() when relevant.

Fixes: 76a832254ab0 ("mtd: partitions: use DT info for parsing partitions with "compatible" prop")
Cc: stable@vger.kernel.org
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
drivers/mtd/mtdpart.c