浏览代码

hwmon: Register thermal zone only if 'dev' parameter was provided

Rgistering a thermal zone uses devm_kzalloc(), which requires
a pointer to the parent device.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Guenter Roeck 8 年之前
父节点
当前提交
319fe15988
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      drivers/hwmon/hwmon.c

+ 1 - 1
drivers/hwmon/hwmon.c

@@ -608,7 +608,7 @@ __hwmon_device_register(struct device *dev, const char *name, void *drvdata,
 	if (err)
 	if (err)
 		goto free_hwmon;
 		goto free_hwmon;
 
 
-	if (chip && chip->ops->read &&
+	if (dev && chip && chip->ops->read &&
 	    chip->info[0]->type == hwmon_chip &&
 	    chip->info[0]->type == hwmon_chip &&
 	    (chip->info[0]->config[0] & HWMON_C_REGISTER_TZ)) {
 	    (chip->info[0]->config[0] & HWMON_C_REGISTER_TZ)) {
 		const struct hwmon_channel_info **info = chip->info;
 		const struct hwmon_channel_info **info = chip->info;