Skip to content

Commit

Permalink
iio: adc: adi-axi-adc: Fix refcount leak in adi_axi_adc_attach_client
Browse files Browse the repository at this point in the history
commit ada7b0c upstream.

of_parse_phandle() returns a node pointer with refcount
incremented, we should use of_node_put() on it when not need anymore.
Add missing of_node_put() to avoid refcount leak.

Fixes: ef04070 ("iio: adc: adi-axi-adc: add support for AXI ADC IP core")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Link: https://lore.kernel.org/r/20220524074517.45268-1-linmq006@gmail.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Yuuoniy authored and gregkh committed Jun 29, 2022
1 parent d40514d commit 501652a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/iio/adc/adi-axi-adc.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,16 +334,19 @@ static struct adi_axi_adc_client *adi_axi_adc_attach_client(struct device *dev)

if (!try_module_get(cl->dev->driver->owner)) {
mutex_unlock(&registered_clients_lock);
of_node_put(cln);
return ERR_PTR(-ENODEV);
}

get_device(cl->dev);
cl->info = info;
mutex_unlock(&registered_clients_lock);
of_node_put(cln);
return cl;
}

mutex_unlock(&registered_clients_lock);
of_node_put(cln);

return ERR_PTR(-EPROBE_DEFER);
}
Expand Down

0 comments on commit 501652a

Please sign in to comment.