lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <201811272153.LGANsXeJ%fengguang.wu@intel.com>
Date:   Tue, 27 Nov 2018 21:16:41 +0800
From:   kbuild test robot <lkp@...el.com>
To:     Anson Huang <anson.huang@....com>
Cc:     kbuild-all@...org, "rui.zhang@...el.com" <rui.zhang@...el.com>,
        "edubezval@...il.com" <edubezval@...il.com>,
        "daniel.lezcano@...aro.org" <daniel.lezcano@...aro.org>,
        "robh+dt@...nel.org" <robh+dt@...nel.org>,
        "mark.rutland@....com" <mark.rutland@....com>,
        "linux-pm@...r.kernel.org" <linux-pm@...r.kernel.org>,
        "devicetree@...r.kernel.org" <devicetree@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        dl-linux-imx <linux-imx@....com>
Subject: Re: [PATCH 1/2] thermal: imx_sc: add i.MX system controller thermal
 support

Hi Anson,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on soc-thermal/next]
[also build test ERROR on v4.20-rc4 next-20181126]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Anson-Huang/thermal-imx_sc-add-i-MX-system-controller-thermal-support/20181127-141933
base:   https://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal.git next
config: i386-allmodconfig (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

>> drivers/thermal/imx_sc_thermal.c:12:10: fatal error: linux/firmware/imx/sci.h: No such file or directory
    #include <linux/firmware/imx/sci.h>
             ^~~~~~~~~~~~~~~~~~~~~~~~~~
   compilation terminated.

coccinelle warnings: (new ones prefixed by >>)

>> drivers/thermal/imx_sc_thermal.c:197:1-6: WARNING: invalid free of devm_ allocated data
   drivers/thermal/imx_sc_thermal.c:199:1-6: WARNING: invalid free of devm_ allocated data
--
>> drivers/thermal/imx_sc_thermal.c:173:6-25: WARNING: Unsigned expression compared with zero: sensor -> resource_id < 0

vim +12 drivers/thermal/imx_sc_thermal.c

  > 12	#include <linux/firmware/imx/sci.h>
    13	#include <linux/module.h>
    14	#include <linux/of.h>
    15	#include <linux/of_device.h>
    16	#include <linux/platform_device.h>
    17	#include <linux/slab.h>
    18	#include <linux/thermal.h>
    19	
    20	#include "thermal_core.h"
    21	
    22	#define IMX_SC_MISC_FUNC_GET_TEMP	13
    23	#define IMX_SC_C_TEMP			0
    24	
    25	struct imx_sc_ipc *thermal_ipc_handle;
    26	
    27	struct imx_sc_sensor {
    28		struct thermal_zone_device *tzd;
    29		unsigned int resource_id;
    30	};
    31	
    32	struct imx_sc_thermal_data {
    33		struct imx_sc_sensor *sensor;
    34	};
    35	
    36	struct imx_sc_msg_req_misc_get_temp {
    37		struct imx_sc_rpc_msg hdr;
    38		u16 resource_id;
    39		u8 type;
    40	} __packed;
    41	
    42	struct imx_sc_msg_resp_misc_get_temp {
    43		struct imx_sc_rpc_msg hdr;
    44		u16 celsius;
    45		u8 tenths;
    46	} __packed;
    47	
    48	static int imx_sc_thermal_get_temp(void *data, int *temp)
    49	{
    50		struct imx_sc_msg_resp_misc_get_temp *resp;
    51		struct imx_sc_msg_req_misc_get_temp msg;
    52		struct imx_sc_rpc_msg *hdr = &msg.hdr;
    53		struct imx_sc_sensor *sensor = data;
    54		int ret;
    55	
    56		msg.resource_id = sensor->resource_id;
    57		msg.type = IMX_SC_C_TEMP;
    58	
    59		hdr->ver = IMX_SC_RPC_VERSION;
    60		hdr->svc = IMX_SC_RPC_SVC_MISC;
    61		hdr->func = IMX_SC_MISC_FUNC_GET_TEMP;
    62		hdr->size = 2;
    63	
    64		ret = imx_scu_call_rpc(thermal_ipc_handle, &msg, true);
    65		if (ret) {
    66			pr_err("read temp sensor %d failed, ret %d\n",
    67				sensor->resource_id, ret);
    68			return ret;
    69		}
    70	
    71		resp = (struct imx_sc_msg_resp_misc_get_temp *)&msg;
    72		*temp = resp->celsius * 1000 + resp->tenths * 100;
    73	
    74		return 0;
    75	}
    76	
    77	static const struct thermal_zone_of_device_ops imx_sc_thermal_ops = {
    78		.get_temp = imx_sc_thermal_get_temp,
    79	};
    80	
    81	static int imx_sc_thermal_register_sensor(struct platform_device *pdev,
    82						  struct imx_sc_sensor *sensor)
    83	{
    84		struct thermal_zone_device *tzd;
    85	
    86		tzd = devm_thermal_zone_of_sensor_register(&pdev->dev,
    87							   sensor->resource_id,
    88							   sensor,
    89							   &imx_sc_thermal_ops);
    90		if (IS_ERR(tzd)) {
    91			dev_err(&pdev->dev, "failed to register sensor: %d\n",
    92				sensor->resource_id);
    93			return -EINVAL;
    94		}
    95	
    96		sensor->tzd = tzd;
    97	
    98		return 0;
    99	}
   100	
   101	static int imx_sc_thermal_get_sensor_id(struct device_node *sensor_np)
   102	{
   103		struct of_phandle_args sensor_specs;
   104		int ret;
   105	
   106		ret = of_parse_phandle_with_args(sensor_np, "thermal-sensors",
   107				"#thermal-sensor-cells",
   108				0, &sensor_specs);
   109		if (ret)
   110			return ret;
   111	
   112		if (sensor_specs.args_count >= 1) {
   113			ret = sensor_specs.args[0];
   114			WARN(sensor_specs.args_count > 1,
   115					"%pOFn: too many cells in sensor specifier %d\n",
   116					sensor_specs.np, sensor_specs.args_count);
   117		} else {
   118			ret = 0;
   119		}
   120	
   121		return ret;
   122	}
   123	
   124	static int imx_sc_thermal_probe(struct platform_device *pdev)
   125	{
   126		struct device_node *np = pdev->dev.of_node;
   127		struct device_node *sensor_np = NULL;
   128		struct imx_sc_thermal_data *data;
   129		struct imx_sc_sensor *sensors;
   130		u32 sensor_num;
   131		int ret, i;
   132	
   133		ret = imx_scu_get_handle(&thermal_ipc_handle);
   134		if (ret) {
   135			if (ret == -EPROBE_DEFER)
   136				return ret;
   137	
   138			dev_err(&pdev->dev, "failed to get ipc handle: %d!\n", ret);
   139			return ret;
   140		}
   141	
   142		data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
   143		if (!data)
   144			return -ENOMEM;
   145	
   146		ret = of_property_read_u32(np, "tsens-num", &sensor_num);
   147		if (ret || !sensor_num) {
   148			dev_err(&pdev->dev, "failed to get valid temp sensor number!\n");
   149			ret = -EINVAL;
   150			goto free_data;
   151		}
   152	
   153		sensors = devm_kzalloc(&pdev->dev, sizeof(*data->sensor) * sensor_num,
   154				       GFP_KERNEL);
   155		if (!sensors) {
   156			ret = -ENOMEM;
   157			goto free_data;
   158		}
   159	
   160		data->sensor = sensors;
   161	
   162		np = of_find_node_by_name(NULL, "thermal-zones");
   163		if (!np) {
   164			ret = -ENODEV;
   165			goto free_sensors;
   166		}
   167	
   168		for (i = 0; i < sensor_num; i++) {
   169			struct imx_sc_sensor *sensor = &data->sensor[i];
   170	
   171			sensor_np = of_get_next_child(np, sensor_np);
   172			sensor->resource_id = imx_sc_thermal_get_sensor_id(sensor_np);
 > 173			if (sensor->resource_id < 0) {
   174				dev_err(&pdev->dev, "invalid sensor resource id: %d\n",
   175					sensor->resource_id);
   176				ret = sensor->resource_id;
   177				goto put_node;
   178			}
   179	
   180			ret = imx_sc_thermal_register_sensor(pdev, sensor);
   181			if (ret) {
   182				dev_err(&pdev->dev, "failed to register thermal sensor: %d\n",
   183					ret);
   184				goto put_node;
   185			}
   186		}
   187	
   188		of_node_put(sensor_np);
   189		of_node_put(np);
   190	
   191		return 0;
   192	
   193	put_node:
   194		of_node_put(np);
   195		of_node_put(sensor_np);
   196	free_sensors:
 > 197		kfree(sensors);
   198	free_data:
   199		kfree(data);
   200	
   201		return ret;
   202	}
   203	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

Download attachment ".config.gz" of type "application/gzip" (64928 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ