Skip to content

Commit 0426584

Browse files
committed
Merge tag 'chrome-platform-v6.19' of git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux
Pull chrome platform updates from Tzung-Bi Shih: "Improvements: - Support legacy probe behavior in cros_ec_lightbar and cros_ec_sensorhub Fixes: - Don't fall back to legacy probe behavior if it isn't a legacy device in cros_usbpd_notify - Fix an UAF after unbinding driver in cros_ec_ishtp" * tag 'chrome-platform-v6.19' of git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux: platform/chrome: sensorhub: Support devices without FIFO_INT_ENABLE platform/chrome: cros_ec_ishtp: Fix UAF after unbinding driver platform/chrome: cros_ec_lightbar: Check if ec supports suspend commands platform/chrome: cros_usbpd_notify: defer probe when parent EC driver isn't ready
2 parents 2aa680d + 52075d2 commit 0426584

4 files changed

Lines changed: 39 additions & 6 deletions

File tree

drivers/platform/chrome/cros_ec_ishtp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,7 @@ static void cros_ec_ishtp_remove(struct ishtp_cl_device *cl_device)
667667

668668
cancel_work_sync(&client_data->work_ishtp_reset);
669669
cancel_work_sync(&client_data->work_ec_evt);
670+
cros_ec_unregister(client_data->ec_dev);
670671
cros_ish_deinit(cros_ish_cl);
671672
ishtp_put_device(cl_device);
672673
}

drivers/platform/chrome/cros_ec_lightbar.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ static unsigned long lb_interval_jiffies = 50 * HZ / 1000;
3030
*/
3131
static bool userspace_control;
3232

33+
/*
34+
* Whether or not the lightbar supports the manual suspend commands.
35+
* The Pixel 2013 (Link) does not while all other devices with a
36+
* lightbar do.
37+
*/
38+
static bool has_manual_suspend;
39+
3340
static ssize_t interval_msec_show(struct device *dev,
3441
struct device_attribute *attr, char *buf)
3542
{
@@ -550,7 +557,7 @@ static int cros_ec_lightbar_probe(struct platform_device *pd)
550557
return -ENODEV;
551558

552559
/* Take control of the lightbar from the EC. */
553-
lb_manual_suspend_ctrl(ec_dev, 1);
560+
has_manual_suspend = (lb_manual_suspend_ctrl(ec_dev, 1) != -EINVAL);
554561

555562
ret = sysfs_create_group(&ec_dev->class_dev.kobj,
556563
&cros_ec_lightbar_attr_group);
@@ -569,14 +576,15 @@ static void cros_ec_lightbar_remove(struct platform_device *pd)
569576
&cros_ec_lightbar_attr_group);
570577

571578
/* Let the EC take over the lightbar again. */
572-
lb_manual_suspend_ctrl(ec_dev, 0);
579+
if (has_manual_suspend)
580+
lb_manual_suspend_ctrl(ec_dev, 0);
573581
}
574582

575583
static int __maybe_unused cros_ec_lightbar_resume(struct device *dev)
576584
{
577585
struct cros_ec_dev *ec_dev = dev_get_drvdata(dev->parent);
578586

579-
if (userspace_control)
587+
if (userspace_control || !has_manual_suspend)
580588
return 0;
581589

582590
return lb_send_empty_cmd(ec_dev, LIGHTBAR_CMD_RESUME);
@@ -586,7 +594,7 @@ static int __maybe_unused cros_ec_lightbar_suspend(struct device *dev)
586594
{
587595
struct cros_ec_dev *ec_dev = dev_get_drvdata(dev->parent);
588596

589-
if (userspace_control)
597+
if (userspace_control || !has_manual_suspend)
590598
return 0;
591599

592600
return lb_send_empty_cmd(ec_dev, LIGHTBAR_CMD_SUSPEND);

drivers/platform/chrome/cros_ec_sensorhub_ring.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,17 @@ int cros_ec_sensorhub_ring_fifo_enable(struct cros_ec_sensorhub *sensorhub,
129129
/* We expect to receive a payload of 4 bytes, ignore. */
130130
if (ret > 0)
131131
ret = 0;
132+
/*
133+
* Some platforms (such as Smaug) don't support the FIFO_INT_ENABLE
134+
* command and the interrupt is always enabled. In the case, it
135+
* returns -EINVAL.
136+
*
137+
* N.B: there is no danger of -EINVAL meaning any other invalid
138+
* parameter since fifo_int_enable.enable is a bool and can never
139+
* be in an invalid range.
140+
*/
141+
else if (ret == -EINVAL)
142+
ret = 0;
132143

133144
return ret;
134145
}

drivers/platform/chrome/cros_usbpd_notify.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77

88
#include <linux/acpi.h>
9+
#include <linux/fwnode.h>
910
#include <linux/mod_devicetable.h>
1011
#include <linux/module.h>
1112
#include <linux/platform_data/cros_ec_proto.h>
@@ -15,6 +16,7 @@
1516
#define DRV_NAME "cros-usbpd-notify"
1617
#define DRV_NAME_PLAT_ACPI "cros-usbpd-notify-acpi"
1718
#define ACPI_DRV_NAME "GOOG0003"
19+
#define CREC_DRV_NAME "GOOG0004"
1820

1921
static BLOCKING_NOTIFIER_HEAD(cros_usbpd_notifier_list);
2022

@@ -98,8 +100,9 @@ static int cros_usbpd_notify_probe_acpi(struct platform_device *pdev)
98100
{
99101
struct cros_usbpd_notify_data *pdnotify;
100102
struct device *dev = &pdev->dev;
101-
struct acpi_device *adev;
103+
struct acpi_device *adev, *parent_adev;
102104
struct cros_ec_device *ec_dev;
105+
struct fwnode_handle *parent_fwnode;
103106
acpi_status status;
104107

105108
adev = ACPI_COMPANION(dev);
@@ -114,8 +117,18 @@ static int cros_usbpd_notify_probe_acpi(struct platform_device *pdev)
114117
/*
115118
* We continue even for older devices which don't have the
116119
* correct device heirarchy, namely, GOOG0003 is a child
117-
* of GOOG0004.
120+
* of GOOG0004. If GOOG0003 is a child of GOOG0004 and we
121+
* can't get a pointer to the Chrome EC device, defer the
122+
* probe function.
118123
*/
124+
parent_fwnode = fwnode_get_parent(dev->fwnode);
125+
if (parent_fwnode) {
126+
parent_adev = to_acpi_device_node(parent_fwnode);
127+
if (parent_adev &&
128+
acpi_dev_hid_match(parent_adev, CREC_DRV_NAME)) {
129+
return -EPROBE_DEFER;
130+
}
131+
}
119132
dev_warn(dev, "Couldn't get Chrome EC device pointer.\n");
120133
}
121134

0 commit comments

Comments
 (0)