Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: lpfc: Fix incorrect request len mbox field when setting trunking via sysfs

When setting trunk modes through sysfs, the SLI_CONFIG mailbox command's
command payload length is incorrectly hardcoded to 12 bytes. SLI_CONFIG's
payload length field should be specified large enough to encompass both the
submailbox command header and the submailbox request itself.

Thus, replace the hardcoded 12 bytes with a clearer calculation by way of
sizeof(struct lpfc_mbx_set_trunk_mode) - sizeof(struct lpfc_sli4_cfg_mhdr).

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Link: https://lore.kernel.org/r/20240628172011.25921-7-justintee8345@gmail.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Justin Tee and committed by
Martin K. Petersen
f65f31ac ede596b1

+4 -1
+4 -1
drivers/scsi/lpfc/lpfc_attr.c
··· 1831 1831 lpfc_set_trunking(struct lpfc_hba *phba, char *buff_out) 1832 1832 { 1833 1833 LPFC_MBOXQ_t *mbox = NULL; 1834 + u32 payload_len; 1834 1835 unsigned long val = 0; 1835 1836 char *pval = NULL; 1836 1837 int rc = 0; ··· 1870 1869 if (!mbox) 1871 1870 return -ENOMEM; 1872 1871 1872 + payload_len = sizeof(struct lpfc_mbx_set_trunk_mode) - 1873 + sizeof(struct lpfc_sli4_cfg_mhdr); 1873 1874 lpfc_sli4_config(phba, mbox, LPFC_MBOX_SUBSYSTEM_FCOE, 1874 1875 LPFC_MBOX_OPCODE_FCOE_FC_SET_TRUNK_MODE, 1875 - 12, LPFC_SLI4_MBX_EMBED); 1876 + payload_len, LPFC_SLI4_MBX_EMBED); 1876 1877 1877 1878 bf_set(lpfc_mbx_set_trunk_mode, 1878 1879 &mbox->u.mqe.un.set_trunk_mode,