[bug report] misc: smpro-errmon: Add dimm training failure syndrome

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Quan Nguyen,

The patch c2c99326cc01: "misc: smpro-errmon: Add dimm training
failure syndrome" from Mar 10, 2023, leads to the following Smatch
static checker warning:

	drivers/misc/smpro-errmon.c:491 smpro_dimm_syndrome_read()
	warn: missing error code? 'ret'

drivers/misc/smpro-errmon.c
    477 static ssize_t smpro_dimm_syndrome_read(struct device *dev, struct device_attribute *da,
    478                                         char *buf, unsigned int slot)
    479 {
    480         struct smpro_errmon *errmon = dev_get_drvdata(dev);
    481         unsigned int data;
    482         int ret;
    483 
    484         ret = regmap_read(errmon->regmap, BOOTSTAGE, &data);
    485         if (ret)
    486                 return ret;
    487 
    488         /* check for valid stage */
    489         data = (data >> 8) & 0xff;
    490         if (data != DIMM_SYNDROME_STAGE)
--> 491                 return ret;

Please either return 0; or return -ERROR_SOMETHING;

    492 
    493         /* Write the slot ID to retrieve Error Syndrome */
    494         ret = regmap_write(errmon->regmap, DIMM_SYNDROME_SEL, slot);
    495         if (ret)
    496                 return ret;
    497 
    498         /* Read the Syndrome error */
    499         ret = regmap_read(errmon->regmap, DIMM_SYNDROME_ERR, &data);
    500         if (ret || !data)
                           ^^^^^
This is incorrect.  I have been meaning to add a static checker warning
for code like this.  It looks like the intent was:

	if (ret)
		return ret;
	if (!data)
		return -EINVAL;

To be honest, I would be tempted to just delete the check for zero and
print a zero in the sysfs_emit().

    501                 return ret;
    502 
    503         return sysfs_emit(buf, "%04x\n", data);
    504 }

regards,
dan carpenter



[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux