|
Takashi Iwai |
2b7403 |
From 950cf957fe34d40d63dfa3bf3968210430b6491e Mon Sep 17 00:00:00 2001
|
|
Takashi Iwai |
2b7403 |
From: Hangyu Hua <hbh25y@gmail.com>
|
|
Takashi Iwai |
2b7403 |
Date: Mon, 18 Apr 2022 16:57:58 +0800
|
|
Takashi Iwai |
2b7403 |
Subject: [PATCH] misc: ocxl: fix possible double free in ocxl_file_register_afu
|
|
Takashi Iwai |
2b7403 |
Git-commit: 950cf957fe34d40d63dfa3bf3968210430b6491e
|
|
Takashi Iwai |
2b7403 |
Patch-mainline: v5.19-rc1
|
|
Takashi Iwai |
2b7403 |
References: git-fixes
|
|
Takashi Iwai |
2b7403 |
|
|
Takashi Iwai |
2b7403 |
info_release() will be called in device_unregister() when info->dev's
|
|
Takashi Iwai |
2b7403 |
reference count is 0. So there is no need to call ocxl_afu_put() and
|
|
Takashi Iwai |
2b7403 |
kfree() again.
|
|
Takashi Iwai |
2b7403 |
|
|
Takashi Iwai |
2b7403 |
Fix this by adding free_minor() and return to err_unregister error path.
|
|
Takashi Iwai |
2b7403 |
|
|
Takashi Iwai |
2b7403 |
Fixes: 75ca758adbaf ("ocxl: Create a clear delineation between ocxl backend & frontend")
|
|
Takashi Iwai |
2b7403 |
Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
|
|
Takashi Iwai |
2b7403 |
Acked-by: Frederic Barrat <fbarrat@linux.ibm.com>
|
|
Takashi Iwai |
2b7403 |
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
|
|
Takashi Iwai |
2b7403 |
Link: https://lore.kernel.org/r/20220418085758.38145-1-hbh25y@gmail.com
|
|
Takashi Iwai |
2b7403 |
Acked-by: Takashi Iwai <tiwai@suse.de>
|
|
Takashi Iwai |
2b7403 |
|
|
Takashi Iwai |
2b7403 |
---
|
|
Takashi Iwai |
2b7403 |
drivers/misc/ocxl/file.c | 2 ++
|
|
Takashi Iwai |
2b7403 |
1 file changed, 2 insertions(+)
|
|
Takashi Iwai |
2b7403 |
|
|
Takashi Iwai |
2b7403 |
diff --git a/drivers/misc/ocxl/file.c b/drivers/misc/ocxl/file.c
|
|
Takashi Iwai |
2b7403 |
index d881f5e40ad9..6777c419a8da 100644
|
|
Takashi Iwai |
2b7403 |
--- a/drivers/misc/ocxl/file.c
|
|
Takashi Iwai |
2b7403 |
+++ b/drivers/misc/ocxl/file.c
|
|
Takashi Iwai |
2b7403 |
@@ -556,7 +556,9 @@ int ocxl_file_register_afu(struct ocxl_afu *afu)
|
|
Takashi Iwai |
2b7403 |
|
|
Takashi Iwai |
2b7403 |
err_unregister:
|
|
Takashi Iwai |
2b7403 |
ocxl_sysfs_unregister_afu(info); // safe to call even if register failed
|
|
Takashi Iwai |
2b7403 |
+ free_minor(info);
|
|
Takashi Iwai |
2b7403 |
device_unregister(&info->dev);
|
|
Takashi Iwai |
2b7403 |
+ return rc;
|
|
Takashi Iwai |
2b7403 |
err_put:
|
|
Takashi Iwai |
2b7403 |
ocxl_afu_put(afu);
|
|
Takashi Iwai |
2b7403 |
free_minor(info);
|
|
Takashi Iwai |
2b7403 |
--
|
|
Takashi Iwai |
2b7403 |
2.35.3
|
|
Takashi Iwai |
2b7403 |
|