Message ID | 20221205115559.3189177-1-shaozhengchao@huawei.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net] net: thunderbolt: fix memory leak in tbnet_open() | expand |
Hi, On Mon, Dec 05, 2022 at 07:55:59PM +0800, Zhengchao Shao wrote: > When tb_ring_alloc_rx() failed in tbnet_open(), it doesn't free ida. > > Fixes: 180b0689425c ("thunderbolt: Allow multiple DMA tunnels over a single XDomain connection") > Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com> > --- > drivers/net/thunderbolt.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/net/thunderbolt.c b/drivers/net/thunderbolt.c > index a52ee2bf5575..70fd61ce15c6 100644 > --- a/drivers/net/thunderbolt.c > +++ b/drivers/net/thunderbolt.c > @@ -916,6 +916,7 @@ static int tbnet_open(struct net_device *dev) > netdev_err(dev, "failed to allocate Rx ring\n"); > tb_ring_free(net->tx_ring.ring); > net->tx_ring.ring = NULL; > + tb_xdomain_release_out_hopid(xd, hopid); Can you move this before tb_ring_free()? Like this: netdev_err(dev, "failed to allocate Rx ring\n"); tb_xdomain_release_out_hopid(xd, hopid); tb_ring_free(net->tx_ring.ring); net->tx_ring.ring = NULL; Otherwise looks good to me.
On 2022/12/5 21:38, Mika Westerberg wrote: > Hi, > > On Mon, Dec 05, 2022 at 07:55:59PM +0800, Zhengchao Shao wrote: >> When tb_ring_alloc_rx() failed in tbnet_open(), it doesn't free ida. >> >> Fixes: 180b0689425c ("thunderbolt: Allow multiple DMA tunnels over a single XDomain connection") >> Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com> >> --- >> drivers/net/thunderbolt.c | 1 + >> 1 file changed, 1 insertion(+) >> >> diff --git a/drivers/net/thunderbolt.c b/drivers/net/thunderbolt.c >> index a52ee2bf5575..70fd61ce15c6 100644 >> --- a/drivers/net/thunderbolt.c >> +++ b/drivers/net/thunderbolt.c >> @@ -916,6 +916,7 @@ static int tbnet_open(struct net_device *dev) >> netdev_err(dev, "failed to allocate Rx ring\n"); >> tb_ring_free(net->tx_ring.ring); >> net->tx_ring.ring = NULL; >> + tb_xdomain_release_out_hopid(xd, hopid); > > Can you move this before tb_ring_free()? Like this: > > netdev_err(dev, "failed to allocate Rx ring\n"); > tb_xdomain_release_out_hopid(xd, hopid); > tb_ring_free(net->tx_ring.ring); > net->tx_ring.ring = NULL; > > Otherwise looks good to me. > Hi Mika: Thank you for your advice. I will send V2. Zhengchao Shao
diff --git a/drivers/net/thunderbolt.c b/drivers/net/thunderbolt.c index a52ee2bf5575..70fd61ce15c6 100644 --- a/drivers/net/thunderbolt.c +++ b/drivers/net/thunderbolt.c @@ -916,6 +916,7 @@ static int tbnet_open(struct net_device *dev) netdev_err(dev, "failed to allocate Rx ring\n"); tb_ring_free(net->tx_ring.ring); net->tx_ring.ring = NULL; + tb_xdomain_release_out_hopid(xd, hopid); return -ENOMEM; } net->rx_ring.ring = ring;
When tb_ring_alloc_rx() failed in tbnet_open(), it doesn't free ida. Fixes: 180b0689425c ("thunderbolt: Allow multiple DMA tunnels over a single XDomain connection") Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com> --- drivers/net/thunderbolt.c | 1 + 1 file changed, 1 insertion(+)