Commit 1405a071 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'hwmon-for-v7.1-rc4' of...

Merge tag 'hwmon-for-v7.1-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging

Pull hwmon fixes from Guenter Roeck:

 - asus_atk0110, acpi_power_meter: Add missing NULL pointer checks

 - lm90: Fix locking and UAF issues

 - sy7636a: Fix sysfs attribute name in documentation

* tag 'hwmon-for-v7.1-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging:
  hwmon: (lm90) Add lock protection to lm90_alert
  hwmon: (lm90) Stop work before releasing hwmon device
  docs: hwmon: sy7636a: fix temperature sysfs attribute name
  hwmon: (asus_atk0110) Check ACPI_COMPANION() against NULL
  hwmon: (acpi_power_meter) Check ACPI_COMPANION() against NULL
parents fe6f8e91 873e919e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -22,5 +22,5 @@ The following sensors are supported
sysfs-Interface
---------------

temp0_input
temp1_input
	- Temperature of external NTC (milli-degree C)
+5 −1
Original line number Diff line number Diff line
@@ -884,10 +884,14 @@ static void acpi_power_meter_notify(acpi_handle handle, u32 event, void *data)

static int acpi_power_meter_probe(struct platform_device *pdev)
{
	struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
	struct acpi_power_meter_resource *resource;
	struct acpi_device *device;
	int res;

	device = ACPI_COMPANION(&pdev->dev);
	if (!device)
		return -ENODEV;

	resource = kzalloc_obj(*resource);
	if (!resource)
		return -ENOMEM;
+6 −1
Original line number Diff line number Diff line
@@ -1273,15 +1273,20 @@ static int atk_probe(struct platform_device *pdev)
	struct acpi_buffer buf;
	union acpi_object *obj;
	struct atk_data *data;
	acpi_handle handle;

	dev_dbg(&pdev->dev, "adding...\n");

	handle = ACPI_HANDLE(&pdev->dev);
	if (!handle)
		return -ENODEV;

	data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
	if (!data)
		return -ENOMEM;

	data->dev = &pdev->dev;
	data->atk_handle = ACPI_HANDLE(&pdev->dev);
	data->atk_handle = handle;
	INIT_LIST_HEAD(&data->sensor_list);
	data->disable_ec = false;

+22 −4
Original line number Diff line number Diff line
@@ -736,6 +736,7 @@ struct lm90_data {
	struct hwmon_chip_info chip;
	struct delayed_work alert_work;
	struct work_struct report_work;
	bool shutdown;		/* true if shutting down */
	bool valid;		/* true if register values are valid */
	bool alarms_valid;	/* true if status register values are valid */
	unsigned long last_updated; /* in jiffies */
@@ -1154,6 +1155,9 @@ static void lm90_report_alarms(struct work_struct *work)

static int lm90_update_alarms_locked(struct lm90_data *data, bool force)
{
	if (data->shutdown)
		return 0;

	if (force || !data->alarms_valid ||
	    time_after(jiffies, data->alarms_updated + msecs_to_jiffies(data->update_interval))) {
		struct i2c_client *client = data->client;
@@ -2584,15 +2588,23 @@ static void lm90_restore_conf(void *_data)
	struct lm90_data *data = _data;
	struct i2c_client *client = data->client;

	cancel_delayed_work_sync(&data->alert_work);
	cancel_work_sync(&data->report_work);

	/* Restore initial configuration */
	if (data->flags & LM90_HAVE_CONVRATE)
		lm90_write_convrate(data, data->convrate_orig);
	lm90_write_reg(client, LM90_REG_CONFIG1, data->config_orig);
}

static void lm90_stop_work(void *_data)
{
	struct lm90_data *data = _data;

	hwmon_lock(data->hwmon_dev);
	data->shutdown = true;
	hwmon_unlock(data->hwmon_dev);
	cancel_delayed_work_sync(&data->alert_work);
	cancel_work_sync(&data->report_work);
}

static int lm90_init_client(struct i2c_client *client, struct lm90_data *data)
{
	struct device_node *np = client->dev.of_node;
@@ -2902,6 +2914,10 @@ static int lm90_probe(struct i2c_client *client)

	data->hwmon_dev = hwmon_dev;

	err = devm_add_action_or_reset(&client->dev, lm90_stop_work, data);
	if (err)
		return err;

	if (client->irq) {
		dev_dbg(dev, "IRQ: %d\n", client->irq);
		err = devm_request_threaded_irq(dev, client->irq,
@@ -2930,7 +2946,8 @@ static void lm90_alert(struct i2c_client *client, enum i2c_alert_protocol type,
		 */
		struct lm90_data *data = i2c_get_clientdata(client);

		if ((data->flags & LM90_HAVE_BROKEN_ALERT) &&
		hwmon_lock(data->hwmon_dev);
		if (!data->shutdown && (data->flags & LM90_HAVE_BROKEN_ALERT) &&
		    (data->current_alarms & data->alert_alarms)) {
			if (!(data->config & 0x80)) {
				dev_dbg(&client->dev, "Disabling ALERT#\n");
@@ -2939,6 +2956,7 @@ static void lm90_alert(struct i2c_client *client, enum i2c_alert_protocol type,
			schedule_delayed_work(&data->alert_work,
				max_t(int, HZ, msecs_to_jiffies(data->update_interval)));
		}
		hwmon_unlock(data->hwmon_dev);
	} else {
		dev_dbg(&client->dev, "Everything OK\n");
	}