lkml.org 
[lkml]   [2022]   [Jun]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.18 095/339] net: ethernet: ti: am65-cpsw-nuss: Fix some refcount leaks
    Date
    From: Miaoqian Lin <linmq006@gmail.com>

    [ Upstream commit 5dd89d2fc438457811cbbec07999ce0d80051ff5 ]

    of_get_child_by_name() returns a node pointer with refcount
    incremented, we should use of_node_put() on it when not need anymore.
    am65_cpsw_init_cpts() and am65_cpsw_nuss_probe() don't release
    the refcount in error case.
    Add missing of_node_put() to avoid refcount leak.

    Fixes: b1f66a5bee07 ("net: ethernet: ti: am65-cpsw-nuss: enable packet timestamping support")
    Fixes: 93a76530316a ("net: ethernet: ti: introduce am65x/j721e gigabit eth subsystem driver")
    Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    drivers/net/ethernet/ti/am65-cpsw-nuss.c | 3 ++-
    1 file changed, 2 insertions(+), 1 deletion(-)

    diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
    index 98969070ed4b..6d978dbf708f 100644
    --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
    +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
    @@ -1797,6 +1797,7 @@ static int am65_cpsw_init_cpts(struct am65_cpsw_common *common)
    if (IS_ERR(cpts)) {
    int ret = PTR_ERR(cpts);

    + of_node_put(node);
    if (ret == -EOPNOTSUPP) {
    dev_info(dev, "cpts disabled\n");
    return 0;
    @@ -2673,9 +2674,9 @@ static int am65_cpsw_nuss_probe(struct platform_device *pdev)
    if (!node)
    return -ENOENT;
    common->port_num = of_get_child_count(node);
    + of_node_put(node);
    if (common->port_num < 1 || common->port_num > AM65_CPSW_MAX_PORTS)
    return -ENOENT;
    - of_node_put(node);

    common->rx_flow_id_base = -1;
    init_completion(&common->tdown_complete);
    --
    2.35.1


    \
     
     \ /
      Last update: 2022-06-13 15:43    [W:4.111 / U:0.220 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site