mfd: cros_ec_dev: Don't advertise junk features on failure
Subsystems (2)
PATCH 1/1 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.
--- drivers/mfd/cros_ec_dev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mfd/cros_ec_dev.c +2 -2
@@ -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 ]);
Signature · 1 line
Sent by a computer through tubes
Hi Stephen,
Quoted 7 lines · Stephen Boyd
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.
Quoted 6 lines
Fixes e4244ebddae2 ("platform/chrome: Introduce a new function to check EC features.")Cc Benson Leung <[email protected]>Cc Enric Balletbo i Serra <[email protected]>Cc Gwendal Grignou <[email protected]>Cc Andy Shevchenko <[email protected]>Signed-off-by Stephen Boyd <[email protected]>
Quoted 24 lines
--- drivers/mfd/cros_ec_dev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/mfd/cros_ec_dev.c +2
-2@@ -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 ]);Signature · 1 line
Sent by a computer through tubes
Signature · 7 lines
Benson Leung Staff Software Engineer Chrome OS Kernel Google Inc. [email protected] Chromium OS Project [email protected]
Lee Jones
AppliedQuoted 13 lines · Stephen Boyd
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.")Cc Benson Leung <[email protected]>Cc Enric Balletbo i Serra <[email protected]>Cc Gwendal Grignou <[email protected]>Cc Andy Shevchenko <[email protected]>Signed-off-by Stephen Boyd <[email protected]>
Quoted 3 lines
--- drivers/mfd/cros_ec_dev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Applied, thanks.
Signature · 4 lines
Lee Jones [李琼斯] Linaro Services Technical Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog