Skip to content

Commit 21a2545

Browse files
Desnes Augusto Nunes do Rosariodavem330
authored andcommitted
ibmvnic: fix empty firmware version and errors cleanup
This patch makes sure that the firmware version is never NULL. Moreover, it also performs some cleanup on the error messages. Fixes: a107311 ("ibmvnic: fix firmware version when no firmware level has been provided by the VIOS server") Signed-off-by: Desnes A. Nunes do Rosario <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4a31a6b commit 21a2545

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

drivers/net/ethernet/ibm/ibmvnic.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3286,7 +3286,7 @@ static void handle_vpd_rsp(union ibmvnic_crq *crq,
32863286
struct ibmvnic_adapter *adapter)
32873287
{
32883288
struct device *dev = &adapter->vdev->dev;
3289-
unsigned char *substr = NULL, *ptr = NULL;
3289+
unsigned char *substr = NULL;
32903290
u8 fw_level_len = 0;
32913291

32923292
memset(adapter->fw_version, 0, 32);
@@ -3306,10 +3306,6 @@ static void handle_vpd_rsp(union ibmvnic_crq *crq,
33063306
substr = strnstr(adapter->vpd->buff, "RM", adapter->vpd->len);
33073307
if (!substr) {
33083308
dev_info(dev, "Warning - No FW level has been provided in the VPD buffer by the VIOS Server\n");
3309-
ptr = strncpy((char *)adapter->fw_version, "N/A",
3310-
3 * sizeof(char));
3311-
if (!ptr)
3312-
dev_err(dev, "Failed to inform that firmware version is unavailable to the adapter\n");
33133309
goto complete;
33143310
}
33153311

@@ -3324,16 +3320,14 @@ static void handle_vpd_rsp(union ibmvnic_crq *crq,
33243320
/* copy firmware version string from vpd into adapter */
33253321
if ((substr + 3 + fw_level_len) <
33263322
(adapter->vpd->buff + adapter->vpd->len)) {
3327-
ptr = strncpy((char *)adapter->fw_version,
3328-
substr + 3, fw_level_len);
3329-
3330-
if (!ptr)
3331-
dev_err(dev, "Failed to isolate FW level string\n");
3323+
strncpy((char *)adapter->fw_version, substr + 3, fw_level_len);
33323324
} else {
33333325
dev_info(dev, "FW substr extrapolated VPD buff\n");
33343326
}
33353327

33363328
complete:
3329+
if (adapter->fw_version[0] == '\0')
3330+
strncpy((char *)adapter->fw_version, "N/A", 3 * sizeof(char));
33373331
complete(&adapter->fw_done);
33383332
}
33393333

0 commit comments

Comments
 (0)