From: Jie Liu <[email protected]>

This patch improves error handling and resource management:

- Add NULL pointer protection in driver remove path:
  * Check cdrv and cdrv->remove before calling remove function
  * Prevent NULL pointer dereference in sxe2_classes_driver_remove
  * Return SXE2_SUCCESS if no driver or remove handler exists

- Allow memory unmap during kernel reset:
  * Remove kernel_reset restriction in sxe2_drv_dev_munmap
  * Enable cleanup operations even when kernel has been reset

Signed-off-by: Jie Liu <[email protected]>
---
 drivers/common/sxe2/sxe2_common.c     | 5 ++++-
 drivers/common/sxe2/sxe2_ioctl_chnl.c | 8 +-------
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/common/sxe2/sxe2_common.c 
b/drivers/common/sxe2/sxe2_common.c
index 5c5db85f29..3f60b2be11 100644
--- a/drivers/common/sxe2/sxe2_common.c
+++ b/drivers/common/sxe2/sxe2_common.c
@@ -465,8 +465,11 @@ static int32_t sxe2_classes_driver_probe(struct 
sxe2_common_device *cdev,
 static int32_t sxe2_classes_driver_remove(struct sxe2_common_device *cdev)
 {
        struct sxe2_class_driver *cdrv = cdev->cdrv;
+       int32_t ret = 0;
 
-       return cdrv->remove(cdev);
+       if (cdrv != NULL && cdrv->remove != NULL)
+               ret = cdrv->remove(cdev);
+       return ret;
 }
 
 static int32_t sxe2_kvargs_validate(struct sxe2_dev_kvargs_info *kv_info)
diff --git a/drivers/common/sxe2/sxe2_ioctl_chnl.c 
b/drivers/common/sxe2/sxe2_ioctl_chnl.c
index a233a78136..3e2fbf572f 100644
--- a/drivers/common/sxe2/sxe2_ioctl_chnl.c
+++ b/drivers/common/sxe2/sxe2_ioctl_chnl.c
@@ -367,16 +367,10 @@ void
 
 RTE_EXPORT_INTERNAL_SYMBOL(sxe2_drv_dev_munmap)
 int32_t
-sxe2_drv_dev_munmap(struct sxe2_common_device *cdev, void *virt, uint64_t len)
+sxe2_drv_dev_munmap(struct sxe2_common_device *cdev __rte_unused, void *virt, 
uint64_t len)
 {
        int32_t ret = 0;
 
-       if (cdev->config.kernel_reset) {
-               ret = -EPERM;
-               PMD_LOG_WARN(COM, "kernel reset, need restart app.");
-               goto l_end;
-       }
-
        PMD_LOG_DEBUG(COM, "Munmap virt=%p, len=0x%"PRIx64"",
                virt, len);
 
-- 
2.52.0

Reply via email to