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] [thread-next>] [day] [month] [year] [list]
Message-ID: <202004040317.DFlq8x22%lkp@intel.com>
Date:   Sat, 4 Apr 2020 03:16:02 +0800
From:   kbuild test robot <lkp@...el.com>
To:     Michał Mirosław <mirq-linux@...e.qmqm.pl>
Cc:     kbuild-all@...ts.01.org, Andrey Smirnov <andrew.smirnov@...il.com>,
        Guenter Roeck <linux@...ck-us.net>,
        Sebastian Reichel <sebastian.reichel@...labora.com>,
        linux-kernel@...r.kernel.org, linux-pm@...r.kernel.org
Subject: Re: [PATCH 2/7] power: supply: core: allow to constify property lists

Hi "Michał,

I love your patch! Yet something to improve:

[auto build test ERROR on power-supply/for-next]
[also build test ERROR on hwmon/hwmon-next linus/master v5.6 next-20200403]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Micha-Miros-aw/power-supply-core-extensions-and-fixes/20200404-004822
base:   https://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git for-next
config: s390-randconfig-a001-20200403 (attached as .config)
compiler: s390-linux-gcc (GCC) 9.3.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=9.3.0 make.cross ARCH=s390 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@...el.com>

All error/warnings (new ones prefixed by >>):

   drivers/power/supply/generic-adc-battery.c: In function 'gab_probe':
>> drivers/power/supply/generic-adc-battery.c:280:17: warning: passing argument 1 of 'memcpy' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
     280 |  memcpy(psy_desc->properties, gab_props, sizeof(gab_props));
         |         ~~~~~~~~^~~~~~~~~~~~
   In file included from include/linux/bitmap.h:9,
                    from include/linux/cpumask.h:12,
                    from include/linux/interrupt.h:8,
                    from drivers/power/supply/generic-adc-battery.c:12:
   include/linux/string.h:369:37: note: expected 'void *' but argument is of type 'const enum power_supply_property *'
     369 | __FORTIFY_INLINE void *memcpy(void *p, const void *q, __kernel_size_t size)
         |                               ~~~~~~^
>> drivers/power/supply/generic-adc-battery.c:302:35: error: assignment of read-only location '*(psy_desc->properties + (sizetype)((long unsigned int)index++ * 4))'
     302 |     psy_desc->properties[index++] =
         |                                   ^

vim +302 drivers/power/supply/generic-adc-battery.c

e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  237  
c8afa6406e60ae drivers/power/generic-adc-battery.c        Bill Pemberton       2012-11-19  238  static int gab_probe(struct platform_device *pdev)
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  239  {
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  240  	struct gab *adc_bat;
297d716f6260cc drivers/power/generic-adc-battery.c        Krzysztof Kozlowski  2015-03-12  241  	struct power_supply_desc *psy_desc;
297d716f6260cc drivers/power/generic-adc-battery.c        Krzysztof Kozlowski  2015-03-12  242  	struct power_supply_config psy_cfg = {};
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  243  	struct gab_platform_data *pdata = pdev->dev.platform_data;
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  244  	int ret = 0;
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  245  	int chan;
932d47448c3caa drivers/power/supply/generic-adc-battery.c H. Nikolaus Schaller 2018-06-26  246  	int index = ARRAY_SIZE(gab_props);
a427503edaaed9 drivers/power/supply/generic-adc-battery.c H. Nikolaus Schaller 2018-06-26  247  	bool any = false;
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  248  
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  249  	adc_bat = devm_kzalloc(&pdev->dev, sizeof(*adc_bat), GFP_KERNEL);
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  250  	if (!adc_bat) {
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  251  		dev_err(&pdev->dev, "failed to allocate memory\n");
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  252  		return -ENOMEM;
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  253  	}
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  254  
297d716f6260cc drivers/power/generic-adc-battery.c        Krzysztof Kozlowski  2015-03-12  255  	psy_cfg.drv_data = adc_bat;
297d716f6260cc drivers/power/generic-adc-battery.c        Krzysztof Kozlowski  2015-03-12  256  	psy_desc = &adc_bat->psy_desc;
297d716f6260cc drivers/power/generic-adc-battery.c        Krzysztof Kozlowski  2015-03-12  257  	psy_desc->name = pdata->battery_info.name;
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  258  
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  259  	/* bootup default values for the battery */
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  260  	adc_bat->cable_plugged = false;
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  261  	adc_bat->status = POWER_SUPPLY_STATUS_DISCHARGING;
297d716f6260cc drivers/power/generic-adc-battery.c        Krzysztof Kozlowski  2015-03-12  262  	psy_desc->type = POWER_SUPPLY_TYPE_BATTERY;
297d716f6260cc drivers/power/generic-adc-battery.c        Krzysztof Kozlowski  2015-03-12  263  	psy_desc->get_property = gab_get_property;
297d716f6260cc drivers/power/generic-adc-battery.c        Krzysztof Kozlowski  2015-03-12  264  	psy_desc->external_power_changed = gab_ext_power_changed;
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  265  	adc_bat->pdata = pdata;
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  266  
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  267  	/*
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  268  	 * copying the static properties and allocating extra memory for holding
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  269  	 * the extra configurable properties received from platform data.
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  270  	 */
297d716f6260cc drivers/power/generic-adc-battery.c        Krzysztof Kozlowski  2015-03-12  271  	psy_desc->properties = kcalloc(ARRAY_SIZE(gab_props) +
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  272  					ARRAY_SIZE(gab_chan_name),
297d716f6260cc drivers/power/generic-adc-battery.c        Krzysztof Kozlowski  2015-03-12  273  					sizeof(*psy_desc->properties),
297d716f6260cc drivers/power/generic-adc-battery.c        Krzysztof Kozlowski  2015-03-12  274  					GFP_KERNEL);
297d716f6260cc drivers/power/generic-adc-battery.c        Krzysztof Kozlowski  2015-03-12  275  	if (!psy_desc->properties) {
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  276  		ret = -ENOMEM;
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  277  		goto first_mem_fail;
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  278  	}
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  279  
297d716f6260cc drivers/power/generic-adc-battery.c        Krzysztof Kozlowski  2015-03-12 @280  	memcpy(psy_desc->properties, gab_props, sizeof(gab_props));
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  281  
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  282  	/*
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  283  	 * getting channel from iio and copying the battery properties
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  284  	 * based on the channel supported by consumer device.
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  285  	 */
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  286  	for (chan = 0; chan < ARRAY_SIZE(gab_chan_name); chan++) {
5aa57f0a655276 drivers/power/generic-adc-battery.c        Guenter Roeck        2013-02-04  287  		adc_bat->channel[chan] = iio_channel_get(&pdev->dev,
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  288  							 gab_chan_name[chan]);
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  289  		if (IS_ERR(adc_bat->channel[chan])) {
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  290  			ret = PTR_ERR(adc_bat->channel[chan]);
64d26f225fefe0 drivers/power/generic-adc-battery.c        Dan Carpenter        2013-02-14  291  			adc_bat->channel[chan] = NULL;
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  292  		} else {
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  293  			/* copying properties for supported channels only */
a427503edaaed9 drivers/power/supply/generic-adc-battery.c H. Nikolaus Schaller 2018-06-26  294  			int index2;
a427503edaaed9 drivers/power/supply/generic-adc-battery.c H. Nikolaus Schaller 2018-06-26  295  
a427503edaaed9 drivers/power/supply/generic-adc-battery.c H. Nikolaus Schaller 2018-06-26  296  			for (index2 = 0; index2 < index; index2++) {
a427503edaaed9 drivers/power/supply/generic-adc-battery.c H. Nikolaus Schaller 2018-06-26  297  				if (psy_desc->properties[index2] ==
a427503edaaed9 drivers/power/supply/generic-adc-battery.c H. Nikolaus Schaller 2018-06-26  298  				    gab_dyn_props[chan])
a427503edaaed9 drivers/power/supply/generic-adc-battery.c H. Nikolaus Schaller 2018-06-26  299  					break;	/* already known */
a427503edaaed9 drivers/power/supply/generic-adc-battery.c H. Nikolaus Schaller 2018-06-26  300  			}
a427503edaaed9 drivers/power/supply/generic-adc-battery.c H. Nikolaus Schaller 2018-06-26  301  			if (index2 == index)	/* really new */
a427503edaaed9 drivers/power/supply/generic-adc-battery.c H. Nikolaus Schaller 2018-06-26 @302  				psy_desc->properties[index++] =
a427503edaaed9 drivers/power/supply/generic-adc-battery.c H. Nikolaus Schaller 2018-06-26  303  					gab_dyn_props[chan];
a427503edaaed9 drivers/power/supply/generic-adc-battery.c H. Nikolaus Schaller 2018-06-26  304  			any = true;
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  305  		}
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  306  	}
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  307  
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  308  	/* none of the channels are supported so let's bail out */
a427503edaaed9 drivers/power/supply/generic-adc-battery.c H. Nikolaus Schaller 2018-06-26  309  	if (!any) {
d211c6e82435df drivers/power/generic-adc-battery.c        Axel Lin             2013-05-25  310  		ret = -ENODEV;
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  311  		goto second_mem_fail;
d211c6e82435df drivers/power/generic-adc-battery.c        Axel Lin             2013-05-25  312  	}
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  313  
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  314  	/*
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  315  	 * Total number of properties is equal to static properties
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  316  	 * plus the dynamic properties.Some properties may not be set
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  317  	 * as come channels may be not be supported by the device.So
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  318  	 * we need to take care of that.
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  319  	 */
932d47448c3caa drivers/power/supply/generic-adc-battery.c H. Nikolaus Schaller 2018-06-26  320  	psy_desc->num_properties = index;
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  321  
297d716f6260cc drivers/power/generic-adc-battery.c        Krzysztof Kozlowski  2015-03-12  322  	adc_bat->psy = power_supply_register(&pdev->dev, psy_desc, &psy_cfg);
297d716f6260cc drivers/power/generic-adc-battery.c        Krzysztof Kozlowski  2015-03-12  323  	if (IS_ERR(adc_bat->psy)) {
297d716f6260cc drivers/power/generic-adc-battery.c        Krzysztof Kozlowski  2015-03-12  324  		ret = PTR_ERR(adc_bat->psy);
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  325  		goto err_reg_fail;
297d716f6260cc drivers/power/generic-adc-battery.c        Krzysztof Kozlowski  2015-03-12  326  	}
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  327  
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  328  	INIT_DELAYED_WORK(&adc_bat->bat_work, gab_work);
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  329  
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  330  	if (gpio_is_valid(pdata->gpio_charge_finished)) {
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  331  		int irq;
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  332  		ret = gpio_request(pdata->gpio_charge_finished, "charged");
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  333  		if (ret)
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  334  			goto gpio_req_fail;
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  335  
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  336  		irq = gpio_to_irq(pdata->gpio_charge_finished);
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  337  		ret = request_any_context_irq(irq, gab_charged,
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  338  				IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  339  				"battery charged", adc_bat);
a5af092245a339 drivers/power/generic-adc-battery.c        Axel Lin             2012-11-16  340  		if (ret < 0)
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  341  			goto err_gpio;
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  342  	}
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  343  
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  344  	platform_set_drvdata(pdev, adc_bat);
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  345  
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  346  	/* Schedule timer to check current status */
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  347  	schedule_delayed_work(&adc_bat->bat_work,
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  348  			msecs_to_jiffies(0));
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  349  	return 0;
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  350  
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  351  err_gpio:
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  352  	gpio_free(pdata->gpio_charge_finished);
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  353  gpio_req_fail:
297d716f6260cc drivers/power/generic-adc-battery.c        Krzysztof Kozlowski  2015-03-12  354  	power_supply_unregister(adc_bat->psy);
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  355  err_reg_fail:
64d26f225fefe0 drivers/power/generic-adc-battery.c        Dan Carpenter        2013-02-14  356  	for (chan = 0; chan < ARRAY_SIZE(gab_chan_name); chan++) {
64d26f225fefe0 drivers/power/generic-adc-battery.c        Dan Carpenter        2013-02-14  357  		if (adc_bat->channel[chan])
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  358  			iio_channel_release(adc_bat->channel[chan]);
64d26f225fefe0 drivers/power/generic-adc-battery.c        Dan Carpenter        2013-02-14  359  	}
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  360  second_mem_fail:
297d716f6260cc drivers/power/generic-adc-battery.c        Krzysztof Kozlowski  2015-03-12  361  	kfree(psy_desc->properties);
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  362  first_mem_fail:
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  363  	return ret;
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  364  }
e60fea794e6ecb drivers/power/generic-adc-battery.c        anish kumar          2012-09-21  365  

:::::: The code at line 302 was first introduced by commit
:::::: a427503edaaed9b75ed9746a654cece7e93e60a8 power: generic-adc-battery: check for duplicate properties copied from iio channels

:::::: TO: H. Nikolaus Schaller <hns@...delico.com>
:::::: CC: Sebastian Reichel <sre@...nel.org>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ