2023-01-04 09:22:51

by Jiasheng Jiang

[permalink] [raw]
Subject: [PATCH] PCI: endpoint: pci-epf-ntb: Add missing check for alloc_workqueue

Add check for the return value of alloc_workqueue since it may return
NULL pointer.

Fixes: 8b821cf76150 ("PCI: endpoint: Add EP function driver to provide NTB functionality")
Signed-off-by: Jiasheng Jiang <[email protected]>
---
drivers/pci/endpoint/functions/pci-epf-ntb.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/pci/endpoint/functions/pci-epf-ntb.c b/drivers/pci/endpoint/functions/pci-epf-ntb.c
index 9a00448c7e61..304956bc0516 100644
--- a/drivers/pci/endpoint/functions/pci-epf-ntb.c
+++ b/drivers/pci/endpoint/functions/pci-epf-ntb.c
@@ -2124,6 +2124,9 @@ static int __init epf_ntb_init(void)

kpcintb_workqueue = alloc_workqueue("kpcintb", WQ_MEM_RECLAIM |
WQ_HIGHPRI, 0);
+ if (!kpcintb_workqueue)
+ return -ENOMEM;
+
ret = pci_epf_register_driver(&epf_ntb_driver);
if (ret) {
destroy_workqueue(kpcintb_workqueue);
--
2.25.1


2023-04-08 09:36:41

by Manivannan Sadhasivam

[permalink] [raw]
Subject: Re: [PATCH] PCI: endpoint: pci-epf-ntb: Add missing check for alloc_workqueue

On Wed, Jan 04, 2023 at 05:16:01PM +0800, Jiasheng Jiang wrote:
> Add check for the return value of alloc_workqueue since it may return
> NULL pointer.
>
> Fixes: 8b821cf76150 ("PCI: endpoint: Add EP function driver to provide NTB functionality")
> Signed-off-by: Jiasheng Jiang <[email protected]>

Reviewed-by: Manivannan Sadhasivam <[email protected]>

- Mani

> ---
> drivers/pci/endpoint/functions/pci-epf-ntb.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/pci/endpoint/functions/pci-epf-ntb.c b/drivers/pci/endpoint/functions/pci-epf-ntb.c
> index 9a00448c7e61..304956bc0516 100644
> --- a/drivers/pci/endpoint/functions/pci-epf-ntb.c
> +++ b/drivers/pci/endpoint/functions/pci-epf-ntb.c
> @@ -2124,6 +2124,9 @@ static int __init epf_ntb_init(void)
>
> kpcintb_workqueue = alloc_workqueue("kpcintb", WQ_MEM_RECLAIM |
> WQ_HIGHPRI, 0);
> + if (!kpcintb_workqueue)
> + return -ENOMEM;
> +
> ret = pci_epf_register_driver(&epf_ntb_driver);
> if (ret) {
> destroy_workqueue(kpcintb_workqueue);
> --
> 2.25.1
>

--
மணிவண்ணன் சதாசிவம்