diff mbox series

[net] qtnfmac: Missing platform_device_unregister() on error in qtnf_core_mac_alloc()

Message ID 20200730064910.37589-1-wanghai38@huawei.com
State Awaiting Upstream
Delegated to: David Miller
Headers show
Series [net] qtnfmac: Missing platform_device_unregister() on error in qtnf_core_mac_alloc() | expand

Commit Message

Wang Hai July 30, 2020, 6:49 a.m. UTC
Add the missing platform_device_unregister() before return from
qtnf_core_mac_alloc() in the error handling case.

Fixes: 616f5701f4ab ("qtnfmac: assign each wiphy to its own virtual platform device")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wang Hai <wanghai38@huawei.com>
---
 drivers/net/wireless/quantenna/qtnfmac/core.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Sergey Matyukevich July 30, 2020, 10:20 a.m. UTC | #1
> Add the missing platform_device_unregister() before return from
> qtnf_core_mac_alloc() in the error handling case.
> 
> Fixes: 616f5701f4ab ("qtnfmac: assign each wiphy to its own virtual platform device")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Wang Hai <wanghai38@huawei.com>
> ---
>  drivers/net/wireless/quantenna/qtnfmac/core.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/wireless/quantenna/qtnfmac/core.c b/drivers/net/wireless/quantenna/qtnfmac/core.c
> index eea777f8acea..6aafff9d4231 100644
> --- a/drivers/net/wireless/quantenna/qtnfmac/core.c
> +++ b/drivers/net/wireless/quantenna/qtnfmac/core.c
> @@ -446,8 +446,11 @@ static struct qtnf_wmac *qtnf_core_mac_alloc(struct qtnf_bus *bus,
>  	}
>  
>  	wiphy = qtnf_wiphy_allocate(bus, pdev);
> -	if (!wiphy)
> +	if (!wiphy) {
> +		if (pdev)
> +			platform_device_unregister(pdev);
>  		return ERR_PTR(-ENOMEM);
> +	}
>  
>  	mac = wiphy_priv(wiphy);

Reviewed-by: Sergey Matyukevich <geomatsi@gmail.com>

Thanks,
Sergey
Kalle Valo Aug. 2, 2020, 3:20 p.m. UTC | #2
Wang Hai <wanghai38@huawei.com> wrote:

> Add the missing platform_device_unregister() before return from
> qtnf_core_mac_alloc() in the error handling case.
> 
> Fixes: 616f5701f4ab ("qtnfmac: assign each wiphy to its own virtual platform device")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Wang Hai <wanghai38@huawei.com>
> Reviewed-by: Sergey Matyukevich <geomatsi@gmail.com>

Patch applied to wireless-drivers-next.git, thanks.

141bc9abbbff qtnfmac: Missing platform_device_unregister() on error in qtnf_core_mac_alloc()
diff mbox series

Patch

diff --git a/drivers/net/wireless/quantenna/qtnfmac/core.c b/drivers/net/wireless/quantenna/qtnfmac/core.c
index eea777f8acea..6aafff9d4231 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/core.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/core.c
@@ -446,8 +446,11 @@  static struct qtnf_wmac *qtnf_core_mac_alloc(struct qtnf_bus *bus,
 	}
 
 	wiphy = qtnf_wiphy_allocate(bus, pdev);
-	if (!wiphy)
+	if (!wiphy) {
+		if (pdev)
+			platform_device_unregister(pdev);
 		return ERR_PTR(-ENOMEM);
+	}
 
 	mac = wiphy_priv(wiphy);