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: <202311200018.xB4hEnZx-lkp@intel.com>
Date:   Mon, 20 Nov 2023 01:04:51 +0800
From:   kernel test robot <lkp@...el.com>
To:     Zhang Xiaoxu <zhangxiaoxu@...wecloud.com>, zhangxiaoxu5@...wei.com,
        weiyongjun1@...wei.com, linux-kernel@...r.kernel.org,
        broonie@...nel.org, rostedt@...dmis.org, mingo@...hat.com,
        frowand.list@...il.com, linux-spi@...r.kernel.org
Cc:     oe-kbuild-all@...ts.linux.dev
Subject: Re: [PATCH v4 -next 2/4] spi: mockup: Add register spi device support

Hi Zhang,

kernel test robot noticed the following build warnings:

[auto build test WARNING on next-20231117]

url:    https://github.com/intel-lab-lkp/linux/commits/Zhang-Xiaoxu/spi-mockup-Add-SPI-controller-testing-driver/20231118-184747
base:   next-20231117
patch link:    https://lore.kernel.org/r/20231118104442.861759-3-zhangxiaoxu%40huawecloud.com
patch subject: [PATCH v4 -next 2/4] spi: mockup: Add register spi device support
config: openrisc-allmodconfig (https://download.01.org/0day-ci/archive/20231120/202311200018.xB4hEnZx-lkp@intel.com/config)
compiler: or1k-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231120/202311200018.xB4hEnZx-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@...el.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202311200018.xB4hEnZx-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In function '__target_online',
       inlined from 'spi_mockup_target_live_store' at drivers/spi/spi-mockup.c:161:9:
>> drivers/spi/spi-mockup.c:108:9: warning: 'strncpy' specified bound depends on the length of the source argument [-Wstringop-truncation]
     108 |         strncpy(info.modalias, target->device_id,
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     109 |                 strlen(target->device_id));
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/spi/spi-mockup.c:108:9: note: length computed here
     108 |         strncpy(info.modalias, target->device_id,
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     109 |                 strlen(target->device_id));
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +/strncpy +108 drivers/spi/spi-mockup.c

    87	
    88	static int __target_online(struct spi_mockup_target *target)
    89	{
    90		struct spi_board_info info = {0};
    91		struct device *dev;
    92	
    93		if (target->spi)
    94			return -EBUSY;
    95	
    96		if (!target->host->pdev)
    97			return -ENODEV;
    98	
    99		target->chip = find_first_zero_bit(target->host->bitmap,
   100						   MOCKUP_CHIPSELECT_MAX);
   101		if (target->chip < 0)
   102			return target->chip;
   103	
   104		if (target->chip > target->host->num_cs)
   105			return -EBUSY;
   106	
   107		info.chip_select = target->chip;
 > 108		strncpy(info.modalias, target->device_id,
   109			strlen(target->device_id));
   110	
   111		target->spi = spi_new_device(target->host->ctrl, &info);
   112		if (!target->spi)
   113			return -ENOMEM;
   114	
   115		bitmap_set(target->host->bitmap, target->chip, 1);
   116	
   117		dev = &target->host->ctrl->dev;
   118		dev_info(dev, "Instantiated device %s at 0x%02x\n",
   119			 info.modalias, info.chip_select);
   120	
   121		return 0;
   122	}
   123	
   124	static int __target_offline(struct spi_mockup_target *target)
   125	{
   126		struct device *dev;
   127	
   128		if (!target->spi)
   129			return -ENODEV;
   130	
   131		dev = &target->host->ctrl->dev;
   132		dev_info(dev, "Deleting device %s at 0x%02hx\n",
   133			 dev_name(&target->spi->dev), target->chip);
   134	
   135		spi_unregister_device(target->spi);
   136		target->spi = NULL;
   137	
   138		bitmap_clear(target->host->bitmap, target->chip, 1);
   139	
   140	
   141		return 0;
   142	}
   143	
   144	static ssize_t
   145	spi_mockup_target_live_store(struct config_item *item,
   146				     const char *buf, size_t len)
   147	{
   148		struct spi_mockup_target *target = to_spi_mockup_target(item);
   149		int ret;
   150		bool res;
   151	
   152		ret = kstrtobool(buf, &res);
   153		if (ret)
   154			return -EINVAL;
   155	
   156		if (!strlen(target->device_id))
   157			return -EINVAL;
   158	
   159		mutex_lock(&target->host->lock);
   160		if (res)
 > 161			ret = __target_online(target);
   162		else
   163			ret = __target_offline(target);
   164		mutex_unlock(&target->host->lock);
   165	
   166		return ret ? ret : len;
   167	}
   168	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ