mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH next] scsi: scsi_debug: Fix missing error code in scsi_debug_init()
@ 2023-04-06  7:46 Harshit Mogalapalli
  2023-04-06  9:33 ` John Garry
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Harshit Mogalapalli @ 2023-04-06  7:46 UTC (permalink / raw)
  Cc: error27, kernel-janitors, Harshit Mogalapalli,
	James E.J. Bottomley, Martin K. Petersen, John Garry, linux-scsi,
	linux-kernel

Smatch reports: drivers/scsi/scsi_debug.c:6996
	scsi_debug_init() warn: missing error code 'ret'

Although it is unlikely that KMEM_CACHE might fail, but if
it does then ret might be zero. So to fix this explicitly
mark ret as "-ENOMEM" and then goto driver_unreg.

Fixes: 1107c7b24ee3 ("scsi: scsi_debug: Dynamically allocate sdebug_queued_cmd")
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
---
This is from static analysis, Only compile tested.
---
 drivers/scsi/scsi_debug.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index cf3f58e8f733..f4fa1035a191 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -6992,8 +6992,10 @@ static int __init scsi_debug_init(void)
 	sdebug_add_host = 0;
 
 	queued_cmd_cache = KMEM_CACHE(sdebug_queued_cmd, SLAB_HWCACHE_ALIGN);
-	if (!queued_cmd_cache)
+	if (!queued_cmd_cache) {
+		ret = -ENOMEM;
 		goto driver_unreg;
+	}
 
 	for (k = 0; k < hosts_to_add; k++) {
 		if (want_store && k == 0) {
-- 
2.38.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-04-19  3:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-06  7:46 [PATCH next] scsi: scsi_debug: Fix missing error code in scsi_debug_init() Harshit Mogalapalli
2023-04-06  9:33 ` John Garry
2023-04-12  1:15 ` Martin K. Petersen
2023-04-19  3:20 ` Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®