firmware: stratix10-svc: add missing gen_pool_destroy() in stratix10_svc_drv_probe()
authorYang Yingliang <yangyingliang@huawei.com>
Tue, 29 Nov 2022 16:36:01 +0000 (10:36 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 10 Mar 2023 08:39:38 +0000 (09:39 +0100)
[ Upstream commit 9175ee1a99d57ec07d66ff572e1d5a724477ab37 ]

In error path in stratix10_svc_drv_probe(), gen_pool_destroy() should be called
to destroy the memory pool that created by svc_create_memory_pool().

Fixes: 7ca5ce896524 ("firmware: add Intel Stratix10 service layer driver")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Signed-off-by: Dinh Nguyen <dinguyen@kernel.org>
Link: https://lore.kernel.org/r/20221129163602.462369-1-dinguyen@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/firmware/stratix10-svc.c

index 7dd0ac1a0cfc7c141d6769e42189a9216d015b9e..4fdd75f1e86eaa3cd6b16f2f0e05f82603ec9d1c 100644 (file)
@@ -994,13 +994,17 @@ static int stratix10_svc_drv_probe(struct platform_device *pdev)
 
        /* allocate service controller and supporting channel */
        controller = devm_kzalloc(dev, sizeof(*controller), GFP_KERNEL);
-       if (!controller)
-               return -ENOMEM;
+       if (!controller) {
+               ret = -ENOMEM;
+               goto err_destroy_pool;
+       }
 
        chans = devm_kmalloc_array(dev, SVC_NUM_CHANNEL,
                                   sizeof(*chans), GFP_KERNEL | __GFP_ZERO);
-       if (!chans)
-               return -ENOMEM;
+       if (!chans) {
+               ret = -ENOMEM;
+               goto err_destroy_pool;
+       }
 
        controller->dev = dev;
        controller->num_chans = SVC_NUM_CHANNEL;
@@ -1015,7 +1019,7 @@ static int stratix10_svc_drv_probe(struct platform_device *pdev)
        ret = kfifo_alloc(&controller->svc_fifo, fifo_size, GFP_KERNEL);
        if (ret) {
                dev_err(dev, "failed to allocate FIFO\n");
-               return ret;
+               goto err_destroy_pool;
        }
        spin_lock_init(&controller->svc_fifo_lock);
 
@@ -1060,6 +1064,8 @@ err_put_device:
        platform_device_put(svc->stratix10_svc_rsu);
 err_free_kfifo:
        kfifo_free(&controller->svc_fifo);
+err_destroy_pool:
+       gen_pool_destroy(genpool);
        return ret;
 }