From: Stephen Boyd Date: Thu, 31 May 2018 06:23:43 +0000 (-0700) Subject: mfd: cros_ec_dev: Don't advertise junk features on failure X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=df7c3bf24f546ab0e5a23b282d34850f2b8eb0d2;p=linux.git mfd: cros_ec_dev: Don't advertise junk features on failure If the feature query fails during this driver's probe, we memset the features bits to 0, but then we continue to overwrite that with whatever junk we read back when the feature probing failed. In the case of a SPI device, it may be complete junk, causing the caller of this function to think certain features are present when they aren't. Don't copy over the bad message on failure so we can fail more gracefully. Fixes: e4244ebddae2 ("platform/chrome: Introduce a new function to check EC features.") Signed-off-by: Stephen Boyd Acked-by: Benson Leung Signed-off-by: Lee Jones --- diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c index 81466264f7fcd..dfc9f131aabe4 100644 --- a/drivers/mfd/cros_ec_dev.c +++ b/drivers/mfd/cros_ec_dev.c @@ -113,10 +113,10 @@ static int cros_ec_check_features(struct cros_ec_dev *ec, int feature) dev_warn(ec->dev, "cannot get EC features: %d/%d\n", ret, msg->result); memset(ec->features, 0, sizeof(ec->features)); + } else { + memcpy(ec->features, msg->data, sizeof(ec->features)); } - memcpy(ec->features, msg->data, sizeof(ec->features)); - dev_dbg(ec->dev, "EC features %08x %08x\n", ec->features[0], ec->features[1]);