Skip to contentSkip to conversation

Wrong usage of kstrtoul() parameter in cxlflash

DISCUSSION Heiner Kallweit 1 participant 1 message Aug 21, 2021 SCSI

lore
Share & tools
lore
#0 lore raw

The following code is used in drivers/scsi/cxlflash/main.c

		memcpy(tmp_buf, &vpd_data[i], WWPN_LEN);
		rc = kstrtoul(tmp_buf, WWPN_LEN, (ulong *)&wwpn[k]);

This seems to be a misinterpretation of kstrtoul parameters. The second one is not a buffer length but the base for the conversion. It may work just by chance because WWPN_LEN is 16, and the VPD string may be a hex number. But definitely WWPN_LEN shouldn't be used here.