[PATCH] staging: gdm724x: fix potential memleak in register_lte_device()

From: Zhang Changzhong
Date: Sun Nov 20 2022 - 03:49:25 EST


The register_lte_device() forgets to free the current netdev in case of
register_netdev() fails, add free_netdev() to fix it.

Compile tested only.

Fixes: 61e121047645 ("staging: gdm7240: adding LTE USB driver")
Signed-off-by: Zhang Changzhong <zhangchangzhong@xxxxxxxxxx>
---
drivers/staging/gdm724x/gdm_lte.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/gdm724x/gdm_lte.c b/drivers/staging/gdm724x/gdm_lte.c
index 671ee88..34ac9e0 100644
--- a/drivers/staging/gdm724x/gdm_lte.c
+++ b/drivers/staging/gdm724x/gdm_lte.c
@@ -905,8 +905,10 @@ int register_lte_device(struct phy_dev *phy_dev,
SET_NETDEV_DEVTYPE(net, &wwan_type);

ret = register_netdev(net);
- if (ret)
+ if (ret) {
+ free_netdev(net);
goto err;
+ }

netif_carrier_on(net);

--
2.9.5