linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [srini-nvmem:for-next 2/4] drivers/nvmem/u-boot-env.c:141:17: sparse: sparse: cast to restricted __le32
@ 2022-08-17 20:54 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2022-08-17 20:54 UTC (permalink / raw)
  To: Rafał Miłecki
  Cc: kbuild-all, linux-kernel, Srinivas Kandagatla, Ahmad Fatoum

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/srini/nvmem.git for-next
head:   74220cdb1b54f4f904311da69a37836b63289bed
commit: f955dc14450695564926711cf9fa8e1d5d854302 [2/4] nvmem: add driver handling U-Boot environment variables
config: openrisc-randconfig-s031-20220818 (https://download.01.org/0day-ci/archive/20220818/202208180411.tn0DH3Se-lkp@intel.com/config)
compiler: or1k-linux-gcc (GCC) 12.1.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # apt-get install sparse
        # sparse version: v0.6.4-39-gce1a6720-dirty
        # https://git.kernel.org/pub/scm/linux/kernel/git/srini/nvmem.git/commit/?id=f955dc14450695564926711cf9fa8e1d5d854302
        git remote add srini-nvmem https://git.kernel.org/pub/scm/linux/kernel/git/srini/nvmem.git
        git fetch --no-tags srini-nvmem for-next
        git checkout f955dc14450695564926711cf9fa8e1d5d854302
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=openrisc SHELL=/bin/bash drivers/nvmem/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>

sparse warnings: (new ones prefixed by >>)
>> drivers/nvmem/u-boot-env.c:141:17: sparse: sparse: cast to restricted __le32
>> drivers/nvmem/u-boot-env.c:141:17: sparse: sparse: cast to restricted __le32
>> drivers/nvmem/u-boot-env.c:141:17: sparse: sparse: cast to restricted __le32
>> drivers/nvmem/u-boot-env.c:141:17: sparse: sparse: cast to restricted __le32
>> drivers/nvmem/u-boot-env.c:141:17: sparse: sparse: cast to restricted __le32
>> drivers/nvmem/u-boot-env.c:141:17: sparse: sparse: cast to restricted __le32

vim +141 drivers/nvmem/u-boot-env.c

   102	
   103	static int u_boot_env_parse(struct u_boot_env *priv)
   104	{
   105		struct device *dev = priv->dev;
   106		size_t crc32_data_offset;
   107		size_t crc32_data_len;
   108		size_t crc32_offset;
   109		size_t data_offset;
   110		size_t data_len;
   111		uint32_t crc32;
   112		uint32_t calc;
   113		size_t bytes;
   114		uint8_t *buf;
   115		int err;
   116	
   117		buf = kcalloc(1, priv->mtd->size, GFP_KERNEL);
   118		if (!buf) {
   119			err = -ENOMEM;
   120			goto err_out;
   121		}
   122	
   123		err = mtd_read(priv->mtd, 0, priv->mtd->size, &bytes, buf);
   124		if ((err && !mtd_is_bitflip(err)) || bytes != priv->mtd->size) {
   125			dev_err(dev, "Failed to read from mtd: %d\n", err);
   126			goto err_kfree;
   127		}
   128	
   129		switch (priv->format) {
   130		case U_BOOT_FORMAT_SINGLE:
   131			crc32_offset = offsetof(struct u_boot_env_image_single, crc32);
   132			crc32_data_offset = offsetof(struct u_boot_env_image_single, data);
   133			data_offset = offsetof(struct u_boot_env_image_single, data);
   134			break;
   135		case U_BOOT_FORMAT_REDUNDANT:
   136			crc32_offset = offsetof(struct u_boot_env_image_redundant, crc32);
   137			crc32_data_offset = offsetof(struct u_boot_env_image_redundant, mark);
   138			data_offset = offsetof(struct u_boot_env_image_redundant, data);
   139			break;
   140		}
 > 141		crc32 = le32_to_cpu(*(uint32_t *)(buf + crc32_offset));
   142		crc32_data_len = priv->mtd->size - crc32_data_offset;
   143		data_len = priv->mtd->size - data_offset;
   144	
   145		calc = crc32(~0, buf + crc32_data_offset, crc32_data_len) ^ ~0L;
   146		if (calc != crc32) {
   147			dev_err(dev, "Invalid calculated CRC32: 0x%08x (expected: 0x%08x)\n", calc, crc32);
   148			err = -EINVAL;
   149			goto err_kfree;
   150		}
   151	
   152		buf[priv->mtd->size - 1] = '\0';
   153		err = u_boot_env_add_cells(priv, buf, data_offset, data_len);
   154		if (err)
   155			dev_err(dev, "Failed to add cells: %d\n", err);
   156	
   157	err_kfree:
   158		kfree(buf);
   159	err_out:
   160		return err;
   161	}
   162	

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-08-17 20:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-17 20:54 [srini-nvmem:for-next 2/4] drivers/nvmem/u-boot-env.c:141:17: sparse: sparse: cast to restricted __le32 kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).