From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild@lists.01.org, Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: lkp@intel.com, kbuild-all@lists.01.org,
Linux Memory Management List <linux-mm@kvack.org>,
Lukasz Luba <lukasz.luba@arm.com>
Subject: [linux-next:master 3779/5053] drivers/thermal/thermal_core.c:1020 __thermal_cooling_device_register() warn: possible memory leak of 'cdev'
Date: Wed, 17 Mar 2021 17:22:15 +0300 [thread overview]
Message-ID: <20210317142215.GA2087@kadam> (raw)
[-- Attachment #1: Type: text/plain, Size: 8476 bytes --]
tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head: fa903833ae344e4f4d798a8b85ba3ef0c5ce96c9
commit: 58483761810087e5ffdf36e84ac1bf26df909097 [3779/5053] thermal/drivers/core: Use a char pointer for the cooling device name
config: x86_64-randconfig-m001-20210317 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
smatch warnings:
drivers/thermal/thermal_core.c:1020 __thermal_cooling_device_register() warn: possible memory leak of 'cdev'
vim +/cdev +1020 drivers/thermal/thermal_core.c
a116b5d44f1445 drivers/thermal/thermal_core.c Eduardo Valentin 2013-09-26 956 static struct thermal_cooling_device *
a116b5d44f1445 drivers/thermal/thermal_core.c Eduardo Valentin 2013-09-26 957 __thermal_cooling_device_register(struct device_node *np,
f991de53a8abef drivers/thermal/thermal_core.c Jean-Francois Dagenais 2019-04-18 958 const char *type, void *devdata,
caca8b803520b0 drivers/thermal/thermal_sys.c Joe Perches 2012-03-21 959 const struct thermal_cooling_device_ops *ops)
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 960 {
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 961 struct thermal_cooling_device *cdev;
4511f7166a2deb drivers/thermal/thermal_core.c Chen Yu 2015-10-30 962 struct thermal_zone_device *pos = NULL;
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 963 int ret;
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 964
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 965 if (!ops || !ops->get_max_state || !ops->get_cur_state ||
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 966 !ops->set_cur_state)
3e6fda5c115982 drivers/thermal/thermal.c Thomas Sujith 2008-02-15 967 return ERR_PTR(-EINVAL);
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 968
95e3ed1513494a drivers/thermal/thermal_core.c Eduardo Valentin 2016-11-07 969 cdev = kzalloc(sizeof(*cdev), GFP_KERNEL);
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 970 if (!cdev)
3e6fda5c115982 drivers/thermal/thermal.c Thomas Sujith 2008-02-15 971 return ERR_PTR(-ENOMEM);
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 972
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 973 ret = ida_simple_get(&thermal_cdev_ida, 0, 0, GFP_KERNEL);
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 974 if (ret < 0)
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 975 goto out_kfree_cdev;
^^^^^^^^^^^^^^^^^^^^
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 976 cdev->id = ret;
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 977
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 978 cdev->type = kstrdup(type ? type : "", GFP_KERNEL);
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 979 if (!cdev->type) {
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 980 ret = -ENOMEM;
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 981 goto out_ida_remove;
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 982 }
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 983
f4a821ce6ed419 drivers/thermal/thermal_sys.c Zhang Rui 2012-07-24 984 mutex_init(&cdev->lock);
b5e4ae620b0627 drivers/thermal/thermal_sys.c Zhang Rui 2012-06-27 985 INIT_LIST_HEAD(&cdev->thermal_instances);
a116b5d44f1445 drivers/thermal/thermal_core.c Eduardo Valentin 2013-09-26 986 cdev->np = np;
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 987 cdev->ops = ops;
5ca0cce5622bf4 drivers/thermal/thermal_core.c Ni Wade 2014-02-17 988 cdev->updated = false;
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 989 cdev->device.class = &thermal_class;
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 990 cdev->devdata = devdata;
8ea229511e06f9 drivers/thermal/thermal_core.c Viresh Kumar 2018-04-02 991 thermal_cooling_device_setup_sysfs(cdev);
354655ea9714e5 drivers/thermal/thermal_sys.c Kay Sievers 2009-01-06 992 dev_set_name(&cdev->device, "cooling_device%d", cdev->id);
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 993 ret = device_register(&cdev->device);
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 994 if (ret)
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 995 goto out_kfree_type;
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 996
7e8ee1e9d7561f drivers/thermal/thermal_sys.c Durgadoss R 2012-09-18 997 /* Add 'this' new cdev to the global cdev list */
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 998 mutex_lock(&thermal_list_lock);
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 999 list_add(&cdev->node, &thermal_cdev_list);
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 1000 mutex_unlock(&thermal_list_lock);
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 1001
7e8ee1e9d7561f drivers/thermal/thermal_sys.c Durgadoss R 2012-09-18 1002 /* Update binding information for 'this' new cdev */
7e8ee1e9d7561f drivers/thermal/thermal_sys.c Durgadoss R 2012-09-18 1003 bind_cdev(cdev);
7e8ee1e9d7561f drivers/thermal/thermal_sys.c Durgadoss R 2012-09-18 1004
4511f7166a2deb drivers/thermal/thermal_core.c Chen Yu 2015-10-30 1005 mutex_lock(&thermal_list_lock);
4511f7166a2deb drivers/thermal/thermal_core.c Chen Yu 2015-10-30 1006 list_for_each_entry(pos, &thermal_tz_list, node)
4511f7166a2deb drivers/thermal/thermal_core.c Chen Yu 2015-10-30 1007 if (atomic_cmpxchg(&pos->need_update, 1, 0))
0e70f466fb910a drivers/thermal/thermal_core.c Srinivas Pandruvada 2016-08-26 1008 thermal_zone_device_update(pos,
0e70f466fb910a drivers/thermal/thermal_core.c Srinivas Pandruvada 2016-08-26 1009 THERMAL_EVENT_UNSPECIFIED);
4511f7166a2deb drivers/thermal/thermal_core.c Chen Yu 2015-10-30 1010 mutex_unlock(&thermal_list_lock);
4511f7166a2deb drivers/thermal/thermal_core.c Chen Yu 2015-10-30 1011
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 1012 return cdev;
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 1013
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 1014 out_kfree_type:
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 1015 kfree(cdev->type);
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 1016 put_device(&cdev->device);
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 1017 out_ida_remove:
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 1018 ida_simple_remove(&thermal_cdev_ida, cdev->id);
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 1019 out_kfree_cdev:
Presumably there was supposed to be a kfree(cdev) here. ;)
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 @1020 return ERR_PTR(ret);
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 1021 }
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 34560 bytes --]
WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild@lists.01.org
Subject: [linux-next:master 3779/5053] drivers/thermal/thermal_core.c:1020 __thermal_cooling_device_register() warn: possible memory leak of 'cdev'
Date: Wed, 17 Mar 2021 17:22:15 +0300 [thread overview]
Message-ID: <20210317142215.GA2087@kadam> (raw)
[-- Attachment #1: Type: text/plain, Size: 8568 bytes --]
tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head: fa903833ae344e4f4d798a8b85ba3ef0c5ce96c9
commit: 58483761810087e5ffdf36e84ac1bf26df909097 [3779/5053] thermal/drivers/core: Use a char pointer for the cooling device name
config: x86_64-randconfig-m001-20210317 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
smatch warnings:
drivers/thermal/thermal_core.c:1020 __thermal_cooling_device_register() warn: possible memory leak of 'cdev'
vim +/cdev +1020 drivers/thermal/thermal_core.c
a116b5d44f1445 drivers/thermal/thermal_core.c Eduardo Valentin 2013-09-26 956 static struct thermal_cooling_device *
a116b5d44f1445 drivers/thermal/thermal_core.c Eduardo Valentin 2013-09-26 957 __thermal_cooling_device_register(struct device_node *np,
f991de53a8abef drivers/thermal/thermal_core.c Jean-Francois Dagenais 2019-04-18 958 const char *type, void *devdata,
caca8b803520b0 drivers/thermal/thermal_sys.c Joe Perches 2012-03-21 959 const struct thermal_cooling_device_ops *ops)
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 960 {
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 961 struct thermal_cooling_device *cdev;
4511f7166a2deb drivers/thermal/thermal_core.c Chen Yu 2015-10-30 962 struct thermal_zone_device *pos = NULL;
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 963 int ret;
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 964
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 965 if (!ops || !ops->get_max_state || !ops->get_cur_state ||
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 966 !ops->set_cur_state)
3e6fda5c115982 drivers/thermal/thermal.c Thomas Sujith 2008-02-15 967 return ERR_PTR(-EINVAL);
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 968
95e3ed1513494a drivers/thermal/thermal_core.c Eduardo Valentin 2016-11-07 969 cdev = kzalloc(sizeof(*cdev), GFP_KERNEL);
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 970 if (!cdev)
3e6fda5c115982 drivers/thermal/thermal.c Thomas Sujith 2008-02-15 971 return ERR_PTR(-ENOMEM);
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 972
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 973 ret = ida_simple_get(&thermal_cdev_ida, 0, 0, GFP_KERNEL);
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 974 if (ret < 0)
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 975 goto out_kfree_cdev;
^^^^^^^^^^^^^^^^^^^^
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 976 cdev->id = ret;
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 977
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 978 cdev->type = kstrdup(type ? type : "", GFP_KERNEL);
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 979 if (!cdev->type) {
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 980 ret = -ENOMEM;
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 981 goto out_ida_remove;
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 982 }
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 983
f4a821ce6ed419 drivers/thermal/thermal_sys.c Zhang Rui 2012-07-24 984 mutex_init(&cdev->lock);
b5e4ae620b0627 drivers/thermal/thermal_sys.c Zhang Rui 2012-06-27 985 INIT_LIST_HEAD(&cdev->thermal_instances);
a116b5d44f1445 drivers/thermal/thermal_core.c Eduardo Valentin 2013-09-26 986 cdev->np = np;
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 987 cdev->ops = ops;
5ca0cce5622bf4 drivers/thermal/thermal_core.c Ni Wade 2014-02-17 988 cdev->updated = false;
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 989 cdev->device.class = &thermal_class;
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 990 cdev->devdata = devdata;
8ea229511e06f9 drivers/thermal/thermal_core.c Viresh Kumar 2018-04-02 991 thermal_cooling_device_setup_sysfs(cdev);
354655ea9714e5 drivers/thermal/thermal_sys.c Kay Sievers 2009-01-06 992 dev_set_name(&cdev->device, "cooling_device%d", cdev->id);
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 993 ret = device_register(&cdev->device);
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 994 if (ret)
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 995 goto out_kfree_type;
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 996
7e8ee1e9d7561f drivers/thermal/thermal_sys.c Durgadoss R 2012-09-18 997 /* Add 'this' new cdev to the global cdev list */
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 998 mutex_lock(&thermal_list_lock);
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 999 list_add(&cdev->node, &thermal_cdev_list);
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 1000 mutex_unlock(&thermal_list_lock);
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 1001
7e8ee1e9d7561f drivers/thermal/thermal_sys.c Durgadoss R 2012-09-18 1002 /* Update binding information for 'this' new cdev */
7e8ee1e9d7561f drivers/thermal/thermal_sys.c Durgadoss R 2012-09-18 1003 bind_cdev(cdev);
7e8ee1e9d7561f drivers/thermal/thermal_sys.c Durgadoss R 2012-09-18 1004
4511f7166a2deb drivers/thermal/thermal_core.c Chen Yu 2015-10-30 1005 mutex_lock(&thermal_list_lock);
4511f7166a2deb drivers/thermal/thermal_core.c Chen Yu 2015-10-30 1006 list_for_each_entry(pos, &thermal_tz_list, node)
4511f7166a2deb drivers/thermal/thermal_core.c Chen Yu 2015-10-30 1007 if (atomic_cmpxchg(&pos->need_update, 1, 0))
0e70f466fb910a drivers/thermal/thermal_core.c Srinivas Pandruvada 2016-08-26 1008 thermal_zone_device_update(pos,
0e70f466fb910a drivers/thermal/thermal_core.c Srinivas Pandruvada 2016-08-26 1009 THERMAL_EVENT_UNSPECIFIED);
4511f7166a2deb drivers/thermal/thermal_core.c Chen Yu 2015-10-30 1010 mutex_unlock(&thermal_list_lock);
4511f7166a2deb drivers/thermal/thermal_core.c Chen Yu 2015-10-30 1011
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 1012 return cdev;
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 1013
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 1014 out_kfree_type:
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 1015 kfree(cdev->type);
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 1016 put_device(&cdev->device);
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 1017 out_ida_remove:
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 1018 ida_simple_remove(&thermal_cdev_ida, cdev->id);
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 1019 out_kfree_cdev:
Presumably there was supposed to be a kfree(cdev) here. ;)
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 @1020 return ERR_PTR(ret);
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 1021 }
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 34560 bytes --]
WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild-all@lists.01.org
Subject: [linux-next:master 3779/5053] drivers/thermal/thermal_core.c:1020 __thermal_cooling_device_register() warn: possible memory leak of 'cdev'
Date: Wed, 17 Mar 2021 17:22:15 +0300 [thread overview]
Message-ID: <20210317142215.GA2087@kadam> (raw)
[-- Attachment #1: Type: text/plain, Size: 8568 bytes --]
tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head: fa903833ae344e4f4d798a8b85ba3ef0c5ce96c9
commit: 58483761810087e5ffdf36e84ac1bf26df909097 [3779/5053] thermal/drivers/core: Use a char pointer for the cooling device name
config: x86_64-randconfig-m001-20210317 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
smatch warnings:
drivers/thermal/thermal_core.c:1020 __thermal_cooling_device_register() warn: possible memory leak of 'cdev'
vim +/cdev +1020 drivers/thermal/thermal_core.c
a116b5d44f1445 drivers/thermal/thermal_core.c Eduardo Valentin 2013-09-26 956 static struct thermal_cooling_device *
a116b5d44f1445 drivers/thermal/thermal_core.c Eduardo Valentin 2013-09-26 957 __thermal_cooling_device_register(struct device_node *np,
f991de53a8abef drivers/thermal/thermal_core.c Jean-Francois Dagenais 2019-04-18 958 const char *type, void *devdata,
caca8b803520b0 drivers/thermal/thermal_sys.c Joe Perches 2012-03-21 959 const struct thermal_cooling_device_ops *ops)
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 960 {
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 961 struct thermal_cooling_device *cdev;
4511f7166a2deb drivers/thermal/thermal_core.c Chen Yu 2015-10-30 962 struct thermal_zone_device *pos = NULL;
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 963 int ret;
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 964
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 965 if (!ops || !ops->get_max_state || !ops->get_cur_state ||
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 966 !ops->set_cur_state)
3e6fda5c115982 drivers/thermal/thermal.c Thomas Sujith 2008-02-15 967 return ERR_PTR(-EINVAL);
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 968
95e3ed1513494a drivers/thermal/thermal_core.c Eduardo Valentin 2016-11-07 969 cdev = kzalloc(sizeof(*cdev), GFP_KERNEL);
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 970 if (!cdev)
3e6fda5c115982 drivers/thermal/thermal.c Thomas Sujith 2008-02-15 971 return ERR_PTR(-ENOMEM);
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 972
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 973 ret = ida_simple_get(&thermal_cdev_ida, 0, 0, GFP_KERNEL);
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 974 if (ret < 0)
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 975 goto out_kfree_cdev;
^^^^^^^^^^^^^^^^^^^^
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 976 cdev->id = ret;
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 977
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 978 cdev->type = kstrdup(type ? type : "", GFP_KERNEL);
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 979 if (!cdev->type) {
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 980 ret = -ENOMEM;
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 981 goto out_ida_remove;
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 982 }
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 983
f4a821ce6ed419 drivers/thermal/thermal_sys.c Zhang Rui 2012-07-24 984 mutex_init(&cdev->lock);
b5e4ae620b0627 drivers/thermal/thermal_sys.c Zhang Rui 2012-06-27 985 INIT_LIST_HEAD(&cdev->thermal_instances);
a116b5d44f1445 drivers/thermal/thermal_core.c Eduardo Valentin 2013-09-26 986 cdev->np = np;
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 987 cdev->ops = ops;
5ca0cce5622bf4 drivers/thermal/thermal_core.c Ni Wade 2014-02-17 988 cdev->updated = false;
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 989 cdev->device.class = &thermal_class;
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 990 cdev->devdata = devdata;
8ea229511e06f9 drivers/thermal/thermal_core.c Viresh Kumar 2018-04-02 991 thermal_cooling_device_setup_sysfs(cdev);
354655ea9714e5 drivers/thermal/thermal_sys.c Kay Sievers 2009-01-06 992 dev_set_name(&cdev->device, "cooling_device%d", cdev->id);
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 993 ret = device_register(&cdev->device);
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 994 if (ret)
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 995 goto out_kfree_type;
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 996
7e8ee1e9d7561f drivers/thermal/thermal_sys.c Durgadoss R 2012-09-18 997 /* Add 'this' new cdev to the global cdev list */
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 998 mutex_lock(&thermal_list_lock);
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 999 list_add(&cdev->node, &thermal_cdev_list);
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 1000 mutex_unlock(&thermal_list_lock);
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 1001
7e8ee1e9d7561f drivers/thermal/thermal_sys.c Durgadoss R 2012-09-18 1002 /* Update binding information for 'this' new cdev */
7e8ee1e9d7561f drivers/thermal/thermal_sys.c Durgadoss R 2012-09-18 1003 bind_cdev(cdev);
7e8ee1e9d7561f drivers/thermal/thermal_sys.c Durgadoss R 2012-09-18 1004
4511f7166a2deb drivers/thermal/thermal_core.c Chen Yu 2015-10-30 1005 mutex_lock(&thermal_list_lock);
4511f7166a2deb drivers/thermal/thermal_core.c Chen Yu 2015-10-30 1006 list_for_each_entry(pos, &thermal_tz_list, node)
4511f7166a2deb drivers/thermal/thermal_core.c Chen Yu 2015-10-30 1007 if (atomic_cmpxchg(&pos->need_update, 1, 0))
0e70f466fb910a drivers/thermal/thermal_core.c Srinivas Pandruvada 2016-08-26 1008 thermal_zone_device_update(pos,
0e70f466fb910a drivers/thermal/thermal_core.c Srinivas Pandruvada 2016-08-26 1009 THERMAL_EVENT_UNSPECIFIED);
4511f7166a2deb drivers/thermal/thermal_core.c Chen Yu 2015-10-30 1010 mutex_unlock(&thermal_list_lock);
4511f7166a2deb drivers/thermal/thermal_core.c Chen Yu 2015-10-30 1011
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 1012 return cdev;
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 1013
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 1014 out_kfree_type:
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 1015 kfree(cdev->type);
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 1016 put_device(&cdev->device);
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 1017 out_ida_remove:
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 1018 ida_simple_remove(&thermal_cdev_ida, cdev->id);
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 1019 out_kfree_cdev:
Presumably there was supposed to be a kfree(cdev) here. ;)
58483761810087 drivers/thermal/thermal_core.c Daniel Lezcano 2021-03-14 @1020 return ERR_PTR(ret);
203d3d4aa48233 drivers/thermal/thermal.c Zhang Rui 2008-01-17 1021 }
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 34560 bytes --]
next reply other threads:[~2021-03-17 14:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-17 14:22 Dan Carpenter [this message]
2021-03-17 14:22 ` [linux-next:master 3779/5053] drivers/thermal/thermal_core.c:1020 __thermal_cooling_device_register() warn: possible memory leak of 'cdev' Dan Carpenter
2021-03-17 14:22 ` Dan Carpenter
2021-03-19 20:22 ` [PATCH] thermal: core: Fix memory leak in the error path Daniel Lezcano
2021-04-15 12:04 ` [thermal: thermal/next] thermal/core: " thermal-bot for Daniel Lezcano
-- strict thread matches above, loose matches on Subject: below --
2021-03-17 12:42 [linux-next:master 3779/5053] drivers/thermal/thermal_core.c:1020 __thermal_cooling_device_register() warn: possible memory leak of 'cdev' kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210317142215.GA2087@kadam \
--to=dan.carpenter@oracle.com \
--cc=daniel.lezcano@linaro.org \
--cc=kbuild-all@lists.01.org \
--cc=kbuild@lists.01.org \
--cc=linux-mm@kvack.org \
--cc=lkp@intel.com \
--cc=lukasz.luba@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.