@@ -8577,7 +8577,8 @@ mpt3sas_base_attach(struct MPT3SAS_ADAPTER *ioc)
/* ctl module internal command bits */
ioc->ctl_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL);
- ioc->ctl_cmds.sense = kzalloc(SCSI_SENSE_BUFFERSIZE, GFP_KERNEL);
+ void *sense = kzalloc(SCSI_SENSE_BUFFERSIZE, GFP_KERNEL);
+ WRITE_ONCE(ioc->ctl_cmds.sense, sense);
ioc->ctl_cmds.status = MPT3_CMD_NOT_USED;
mutex_init(&ioc->ctl_cmds.mutex);
@@ -1096,7 +1096,7 @@ _ctl_do_mpt_command(struct MPT3SAS_ADAPTER *ioc, struct mpt3_ioctl_command karg,
MPI2_FUNCTION_NVME_ENCAPSULATED) ? NVME_ERROR_RESPONSE_SIZE :
SCSI_SENSE_BUFFERSIZE;
sz = min_t(u32, karg.max_sense_bytes, sz_arg);
- if (copy_to_user(karg.sense_data_ptr, ioc->ctl_cmds.sense,
+ if (copy_to_user(karg.sense_data_ptr, READ_ONCE(ioc->ctl_cmds.sense),
sz)) {
pr_err("failure at %s:%d/%s()!\n", __FILE__,
__LINE__, __func__);