Skip to content

Commit

Permalink
of: property: decrement node refcount in of_fwnode_get_reference_args()
Browse files Browse the repository at this point in the history
In of_fwnode_get_reference_args(), the refcount of of_args.np has
been incremented in the case of successful return from
of_parse_phandle_with_args() or of_parse_phandle_with_fixed_args().

Decrement the refcount if of_args is not returned to the caller of
of_fwnode_get_reference_args().

Fixes: 3e3119d ("device property: Introduce fwnode_property_get_reference_args")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Frank Rowand <frowand.list@gmail.com>
Link: https://lore.kernel.org/r/20221121023209.3909759-1-yangyingliang@huawei.com
Signed-off-by: Rob Herring <robh@kernel.org>
  • Loading branch information
Yang Yingliang authored and Rob Herring committed Nov 22, 2022
1 parent 917c362 commit 60d865b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/of/property.c
Original file line number Diff line number Diff line change
Expand Up @@ -993,8 +993,10 @@ of_fwnode_get_reference_args(const struct fwnode_handle *fwnode,
nargs, index, &of_args);
if (ret < 0)
return ret;
if (!args)
if (!args) {
of_node_put(of_args.np);
return 0;
}

args->nargs = of_args.args_count;
args->fwnode = of_fwnode_handle(of_args.np);
Expand Down

0 comments on commit 60d865b

Please sign in to comment.