Skip to content

Commit b952eb2

Browse files
bvanasschemartinkpetersen
authored andcommitted
scsi: scsi_debug: Allocate the MODE SENSE response from the heap
Make the MODE SENSE response buffer larger and allocate it from the heap. This patch prepares for adding support for the IO Advice Hints Grouping mode page. Suggested-by: Douglas Gilbert <dgilbert@interlog.com> Cc: Douglas Gilbert <dgilbert@interlog.com> Tested-by: Douglas Gilbert <dgilbert@interlog.com> Signed-off-by: Bart Van Assche <bvanassche@acm.org> Link: https://lore.kernel.org/r/20240130214911.1863909-17-bvanassche@acm.org Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent f19c3e4 commit b952eb2

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

drivers/scsi/scsi_debug.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include <linux/prefetch.h>
4444
#include <linux/debugfs.h>
4545
#include <linux/async.h>
46+
#include <linux/cleanup.h>
4647

4748
#include <net/checksum.h>
4849

@@ -2631,7 +2632,8 @@ static int resp_sas_sha_m_spg(unsigned char *p, int pcontrol)
26312632
return sizeof(sas_sha_m_pg);
26322633
}
26332634

2634-
#define SDEBUG_MAX_MSENSE_SZ 256
2635+
/* PAGE_SIZE is more than necessary but provides room for future expansion. */
2636+
#define SDEBUG_MAX_MSENSE_SZ PAGE_SIZE
26352637

26362638
static int resp_mode_sense(struct scsi_cmnd *scp,
26372639
struct sdebug_dev_info *devip)
@@ -2642,10 +2644,13 @@ static int resp_mode_sense(struct scsi_cmnd *scp,
26422644
int target_dev_id;
26432645
int target = scp->device->id;
26442646
unsigned char *ap;
2645-
unsigned char arr[SDEBUG_MAX_MSENSE_SZ];
2647+
unsigned char *arr __free(kfree);
26462648
unsigned char *cmd = scp->cmnd;
26472649
bool dbd, llbaa, msense_6, is_disk, is_zbc;
26482650

2651+
arr = kzalloc(SDEBUG_MAX_MSENSE_SZ, GFP_ATOMIC);
2652+
if (!arr)
2653+
return -ENOMEM;
26492654
dbd = !!(cmd[1] & 0x8); /* disable block descriptors */
26502655
pcontrol = (cmd[2] & 0xc0) >> 6;
26512656
pcode = cmd[2] & 0x3f;

0 commit comments

Comments
 (0)