Re: [PATCH V3] scsi: lpfc: Fix a possible null pointer dereference

From: Justin Tee
Date: Thu Jun 20 2024 - 12:44:23 EST


Hi Huai-Yuan,

Sorry for noticing this later, but a return len while len is 0 would
result in a silent $(cat /sys/class/scsi_host/host*/lpfc_xcvr_data).

Perhaps, it's better to log something to at least notify the user why
SFP information was not able to be collected.

How about something like this?

/* Get transceiver information */
rdp_context = kmalloc(sizeof(*rdp_context), GFP_KERNEL);
+ if (!rdp_context) {
+ len = scnprintf(buf, PAGE_SIZE - len,
+ "SFP info NA: alloc failure\n");
+ return len;
+ }

rc = lpfc_get_sfp_info_wait(phba, rdp_context);
if (rc) {


Thanks,
Justin Tee