[PATCH 1/4] [v4][POWERPC] refactor dcr code
Stephen Rothwell
sfr at canb.auug.org.au
Tue May 6 13:40:06 EST 2008
Hi Stephen,
On Mon, 5 May 2008 10:56:38 -0700 Stephen Neuendorffer <stephen.neuendorffer at xilinx.com> wrote:
>
> +static struct device_node *find_dcr_parent(struct device_node *node)
> +{
> + struct device_node *par, *tmp;
> + const u32 *p;
> +
> + for (par = of_node_get(node); par;) {
> + if (of_get_property(par, "dcr-controller", NULL))
> + break;
> + p = of_get_property(par, "dcr-parent", NULL);
> + tmp = par;
> + if (p == NULL)
> + par = of_get_parent(par);
> + else
> + par = of_find_node_by_phandle(*p);
> + of_node_put(tmp);
> + }
> + return par;
> +}
.
.
> +dcr_host_t dcr_map_generic(struct device_node *dev,
> + unsigned int dcr_n,
> + unsigned int dcr_c)
> +{
> + dcr_host_t host;
> + struct device_node *dp;
> + const char *prop;
> +
> + host.type = DCR_HOST_INVALID;
> +
> + dp = find_dcr_parent(dev);
> + if (dp == NULL)
> + return host;
> +
> + prop = of_get_property(dp, "dcr-access-method", NULL);
> +
> + pr_debug("dcr_map_generic(dcr-access-method = %s)\n", prop);
> +
> + if (!strcmp(prop, "native")) {
> + host.type = DCR_HOST_NATIVE;
> + host.host.native = dcr_map_native(dev, dcr_n, dcr_c);
> + } else if (!strcmp(prop, "mmio")) {
> + host.type = DCR_HOST_MMIO;
> + host.host.mmio = dcr_map_mmio(dev, dcr_n, dcr_c);
> + }
> +
> + return host;
Since find_dcr_parent has done a of_node_get on its return value, you
leak a reference to dp here i.e. you need an of_node_put(dp) before you
return.
--
Cheers,
Stephen Rothwell sfr at canb.auug.org.au
http://www.canb.auug.org.au/~sfr/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.ozlabs.org/pipermail/linuxppc-dev/attachments/20080506/a54fe9ab/attachment.pgp>
More information about the Linuxppc-dev
mailing list