Skip to content

Commit

Permalink
scsi: scsi_debug: Fix missing error code in scsi_debug_init()
Browse files Browse the repository at this point in the history
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: 1107c7b ("scsi: scsi_debug: Dynamically allocate sdebug_queued_cmd")
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Link: https://lore.kernel.org/r/20230406074607.3637097-1-harshit.m.mogalapalli@oracle.com
Reviewed-by: John Garry <john.g.garry@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
  • Loading branch information
Harshit Mogalapalli authored and Martin K. Petersen committed Apr 12, 2023
1 parent e01e229 commit b32283d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/scsi/scsi_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit b32283d

Please sign in to comment.