Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp270602imm; Wed, 30 May 2018 23:25:40 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLMLofcbS/qHUNULnZLhyay3koanCXBNL0rn3PgexpFjKJkiKKywV/pYgg+MGSGMfkOvZnK X-Received: by 2002:a63:7207:: with SMTP id n7-v6mr4440274pgc.195.1527747940109; Wed, 30 May 2018 23:25:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527747940; cv=none; d=google.com; s=arc-20160816; b=vov/BV+cHyj/tiO8AWgEH/EPCGZDL+v0y1Rj4NwvUPbewYRVB/86lPxkVjUQIvqR47 fAqS5pasow9+yPDfv1YDXxbQZmaLxoxkXK3Sl7VRX+OHLXZQC3wkOhi72GwnrDioBSQK 32ZyOhOYKAjN2JA/V+6S9jZDsP06XMSxM9aWNKeqg+XenXGmDgEho/9xVMKJ9Iugs2tv sri5wAY5OGdQCvLjDsEWXVWujnSXsR99dpJ1X8El6ZyhDE2cOyy+OifLszBl7ZgyKtiA pI1DOk+bn8evJ3BeeaJwEX32cheLDI7tQ6aZuELSlvR1WFIAiYSo1sfAMMBn0aaG8CXm oKWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=XSYwZwuX5p6j9GGfiPpIZq7C/Ae1BGWlmAz2dHOqjGg=; b=uerjdm9VPouJsb4spf1iBtpS3MdJLoGcastp7PPgM66bry/q5G251hSqWWjSS/7KzA E5ENYNJkHl5vM/UjHLqzE3pK08rTujkPez0jRCNUXCSsd4dlvonItXTPrpZ4F8Qb8Rgt ADRicDbtY7uz0S/mL4OSMot8Xi5nfgFgg4QSjsgKOFfc7JWi5ZxVUWkDsqWQc15X6Zg3 7rzrkmsf7bUrID9ipEZi80HbcPNc/J8M96Mgxast6Bc4vM+szXq3+2eEjFNKvB2oN02g T8ikmO2EUCv07H7ukLutQBjWRUhUVNWvTFVwox43KcaX+P6OjKIZldTl7UvSNtGhhmUn WuOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=cbf1ITSQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v25-v6si1144730pfn.191.2018.05.30.23.25.24; Wed, 30 May 2018 23:25:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=cbf1ITSQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753968AbeEaGXs (ORCPT + 99 others); Thu, 31 May 2018 02:23:48 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:38684 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751037AbeEaGXr (ORCPT ); Thu, 31 May 2018 02:23:47 -0400 Received: by mail-pf0-f196.google.com with SMTP id b74-v6so6798152pfl.5 for ; Wed, 30 May 2018 23:23:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=XSYwZwuX5p6j9GGfiPpIZq7C/Ae1BGWlmAz2dHOqjGg=; b=cbf1ITSQSM2OQmxWJtrA27yBA+BCAyxHSIj55ijmKXodCUReIrqn/bmpt7tOQEa1kJ GxhvsfDPY0XX3L4ZHi0Rvh59kxDjRHVBve+AXWPIDKTMbzx9+XzV7ryhe4uBx82v86oF FkZltec8i0lU389nSJ5/bqGo+dKa86wku0vvo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=XSYwZwuX5p6j9GGfiPpIZq7C/Ae1BGWlmAz2dHOqjGg=; b=JB5oF84oYUUeV382SLbDmCLfiXS3gNUFPYkae4bVqJufmA+XYAXAqxpf2jFmseNauJ 4EvHoANu2g7V55135LB7V+AubnEpSsWD0S6j6X9rMuf7dPPHR5kOrgZwpZNh0GTAiPRm YYh1gLpzUjwdJ/QUpexEFGiOF8Jy+VlrSrzNaG/FNYnshxLQnbb6MGQLWm/fRealffog 3XGtaIkK/5WMbL0MVoM8bEEpIjBVDryjgu2+jsJfyuuIfdOK6UGJ45uHyBwmH25QnssL tQowM7lGTynmXGQD2DwXs+WGVtdPJNQtJlH4oeJRXkEAPuOhf+555u9TW2RjO/4oMGal mhSQ== X-Gm-Message-State: ALKqPwe25PZBHW0GaaQHc4ij5WhvveSe638/tm5hNBmfLEy0SlUW9btI u7aJr+SZhOF72C/f4nvVigpLh2exwHk= X-Received: by 2002:a63:6dc3:: with SMTP id i186-v6mr4613786pgc.316.1527747826578; Wed, 30 May 2018 23:23:46 -0700 (PDT) Received: from swboyd.mtv.corp.google.com ([2620:0:1000:1511:d30e:62c6:f82c:ff40]) by smtp.gmail.com with ESMTPSA id i7-v6sm13300892pfa.34.2018.05.30.23.23.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 May 2018 23:23:45 -0700 (PDT) From: Stephen Boyd To: Lee Jones Cc: linux-kernel@vger.kernel.org, Benson Leung , Enric Balletbo i Serra , Gwendal Grignou , Andy Shevchenko Subject: [PATCH] mfd: cros_ec_dev: Don't advertise junk features on failure Date: Wed, 30 May 2018 23:23:43 -0700 Message-Id: <20180531062343.243720-1-swboyd@chromium.org> X-Mailer: git-send-email 2.17.0.921.gf22659ad46-goog Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Cc: Enric Balletbo i Serra Cc: Gwendal Grignou Cc: Andy Shevchenko Signed-off-by: Stephen Boyd --- drivers/mfd/cros_ec_dev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c index 1d6dc5c7a19d..d37c79426c87 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]); -- Sent by a computer through tubes