Explorar el Código

msm: synx: Fix to prevent stale addresses after synx_init failure

Adding cdev_del() to delete the synx cdev which is not deleted
during synx_init failure condition.

Change-Id: I9990ff36a500453cd972c45f06fb57e8a0143a1d
Signed-off-by: Pravin Kumar Ravi <[email protected]>
Pravin Kumar Ravi hace 1 año
padre
commit
8b3cd55815
Se han modificado 1 ficheros con 8 adiciones y 1 borrados
  1. 8 1
      msm/synx/synx.c

+ 8 - 1
msm/synx/synx.c

@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
  * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved.
- * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2022-2024, Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include <linux/atomic.h>
@@ -2827,6 +2827,11 @@ static int __init synx_init(void)
 	}
 
 	synx_dev->class = class_create(THIS_MODULE, SYNX_DEVICE_NAME);
+
+	if (IS_ERR(synx_dev->class)) {
+		rc = PTR_ERR(synx_dev->class);
+		goto err_class_create;
+	}
 	device_create(synx_dev->class, NULL, synx_dev->dev,
 		NULL, SYNX_DEVICE_NAME);
 
@@ -2877,6 +2882,8 @@ err:
 fail:
 	device_destroy(synx_dev->class, synx_dev->dev);
 	class_destroy(synx_dev->class);
+err_class_create:
+	cdev_del(&synx_dev->cdev);
 reg_fail:
 	unregister_chrdev_region(synx_dev->dev, 1);
 alloc_fail: