Hi Stephen,
On Mon, 5 May 2008 10:56:38 -0700 Stephen Neuendorffer <[EMAIL PROTECTED]>
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 [EMAIL PROTECTED]
http://www.canb.auug.org.au/~sfr/
pgpK2ufAulMkU.pgp
Description: PGP signature
_______________________________________________ Linuxppc-dev mailing list [email protected] https://ozlabs.org/mailman/listinfo/linuxppc-dev
