From: kernel test robot <lkp@intel.com>
To: "Rafał Miłecki" <rafal@milecki.pl>
Cc: kbuild-all@lists.01.org, linux-kernel@vger.kernel.org,
Srinivas Kandagatla <srinivas.kandagatla@linaro.org>,
Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [srini-nvmem:for-next 2/4] drivers/nvmem/u-boot-env.c:141:17: sparse: sparse: cast to restricted __le32
Date: Thu, 18 Aug 2022 04:54:36 +0800 [thread overview]
Message-ID: <202208180411.tn0DH3Se-lkp@intel.com> (raw)
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
reply other threads:[~2022-08-17 20:55 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=202208180411.tn0DH3Se-lkp@intel.com \
--to=lkp@intel.com \
--cc=a.fatoum@pengutronix.de \
--cc=kbuild-all@lists.01.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rafal@milecki.pl \
--cc=srinivas.kandagatla@linaro.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox