lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20260208035347.276181-1-n7l8m4@u.northwestern.edu>
Date: Sun,  8 Feb 2026 03:53:47 +0000
From: Ziyi Guo <n7l8m4@...orthwestern.edu>
To: Kashyap Desai <kashyap.desai@...adcom.com>,
	Sumit Saxena <sumit.saxena@...adcom.com>,
	Shivasharan S <shivasharan.srikanteshwara@...adcom.com>,
	Chandrakanth patil <chandrakanth.patil@...adcom.com>
Cc: "James E . J . Bottomley" <James.Bottomley@...senPartnership.com>,
	"Martin K . Petersen" <martin.petersen@...cle.com>,
	megaraidlinux.pdl@...adcom.com,
	linux-scsi@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	Ziyi Guo <n7l8m4@...orthwestern.edu>
Subject: [PATCH] scsi: megaraid: add mega_proc_dir_entry check when proc_mkdir fails

megaraid_init() calls proc_mkdir("megaraid", NULL) but only logs a
warning and continues when it fails. If pci_register_driver()
subsequently fails, the error path unconditionally calls
remove_proc_entry("megaraid", NULL) for a directory that was never
created, triggering a WARN at fs/proc/generic.c:736.

The same issue exists in megaraid_exit(): if proc_mkdir() failed during
init but the module loaded successfully (pci_register_driver succeeded),
module removal unconditionally calls remove_proc_entry("megaraid", NULL).

Guard both remove_proc_entry() calls with a check for
mega_proc_dir_entry being non-NULL, aligned with the check of 
`if (!mega_proc_dir_entry)` during megaraid_init() creation stage

Signed-off-by: Ziyi Guo <n7l8m4@...orthwestern.edu>
---
 drivers/scsi/megaraid.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
index a00622c0c526..ab901ad6c480 100644
--- a/drivers/scsi/megaraid.c
+++ b/drivers/scsi/megaraid.c
@@ -4589,7 +4589,8 @@ static int __init megaraid_init(void)
 	error = pci_register_driver(&megaraid_pci_driver);
 	if (error) {
 #ifdef CONFIG_PROC_FS
-		remove_proc_entry("megaraid", NULL);
+		if (mega_proc_dir_entry)
+			remove_proc_entry("megaraid", NULL);
 #endif
 		return error;
 	}
@@ -4619,7 +4620,8 @@ static void __exit megaraid_exit(void)
 	pci_unregister_driver(&megaraid_pci_driver);
 
 #ifdef CONFIG_PROC_FS
-	remove_proc_entry("megaraid", NULL);
+	if (mega_proc_dir_entry)
+		remove_proc_entry("megaraid", NULL);
 #endif
 }
 
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ