* [ammarfaizi2-block:dhowells/linux-fs/netfs-maple 39/40] fs/afs/write.c:347:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is true
@ 2022-04-05 13:31 kernel test robot
0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2022-04-05 13:31 UTC (permalink / raw)
To: David Howells; +Cc: llvm, kbuild-all, GNU/Weeb Mailing List, linux-kernel
tree: https://github.com/ammarfaizi2/linux-block dhowells/linux-fs/netfs-maple
head: 674eea41fc70a740ff83ec590f9833f805852464
commit: e3f5aec34955d83f706c49c395274da333dd726d [39/40] afs: [DON'T MERGE] Implement trivial content crypto for testing purposes
config: i386-randconfig-a015 (https://download.01.org/0day-ci/archive/20220405/[email protected]/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project c4a1b07d0979e7ff20d7d541af666d822d66b566)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/ammarfaizi2/linux-block/commit/e3f5aec34955d83f706c49c395274da333dd726d
git remote add ammarfaizi2-block https://github.com/ammarfaizi2/linux-block
git fetch --no-tags ammarfaizi2-block dhowells/linux-fs/netfs-maple
git checkout e3f5aec34955d83f706c49c395274da333dd726d
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash fs/afs/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>
All warnings (new ones prefixed by >>):
>> fs/afs/write.c:347:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if (!buf)
^~~~
fs/afs/write.c:417:9: note: uninitialized use occurs here
return ret;
^~~
fs/afs/write.c:347:2: note: remove the 'if' if its condition is always false
if (!buf)
^~~~~~~~~
fs/afs/write.c:329:9: note: initialize the variable 'ret' to silence this warning
int ret;
^
= 0
fs/afs/write.c:454:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if (!buf)
^~~~
fs/afs/write.c:524:9: note: uninitialized use occurs here
return ret;
^~~
fs/afs/write.c:454:2: note: remove the 'if' if its condition is always false
if (!buf)
^~~~~~~~~
fs/afs/write.c:436:9: note: initialize the variable 'ret' to silence this warning
int ret;
^
= 0
2 warnings generated.
vim +347 fs/afs/write.c
312
313 /*
314 * Encrypt part of a write for fscrypt. The caller reserved an extra
315 * scatterlist element before each of source_sg and dest_sg for our purposes,
316 * should we need them.
317 */
318 int afs_encrypt_block(struct netfs_io_request *wreq, loff_t pos, size_t len,
319 struct scatterlist *source_sg, unsigned int n_source,
320 struct scatterlist *dest_sg, unsigned int n_dest)
321 {
322 struct crypto_sync_skcipher *ci;
323 struct skcipher_request *req;
324 struct crypto_skcipher *tfm;
325 struct sha256_state *sha;
326 void *buf = NULL;
327 __be64 *session_key;
328 u8 *iv, *b0;
329 int ret;
330
331 ci = crypto_alloc_sync_skcipher("cts(cbc(aes))", 0, 0);
332 if (IS_ERR(ci)) {
333 ret = PTR_ERR(ci);
334 pr_err("Can't allocate cipher: %d\n", ret);
335 goto error;
336 }
337 tfm = &ci->base;
338
339 if (crypto_sync_skcipher_ivsize(ci) > 16 &&
340 crypto_sync_skcipher_blocksize(ci) > 16) {
341 pr_err("iv wrong size: %u\n", crypto_sync_skcipher_ivsize(ci));
342 ret = -EINVAL;
343 goto error_ci;
344 }
345
346 buf = kzalloc(4 * 16 + sizeof(*sha), GFP_KERNEL);
> 347 if (!buf)
348 goto error_ci;
349 b0 = buf;
350 iv = buf + 32;
351 session_key = buf + 48;
352 session_key[0] = cpu_to_be64(pos);
353 session_key[1] = cpu_to_le64(pos);
354 sha = buf + 64;
355
356 *(__be64 *)iv = pos;
357
358 ret = crypto_sync_skcipher_setkey(ci, (u8 *)session_key, 16);
359 if (ret < 0) {
360 pr_err("Setkey failed: %d\n", ret);
361 goto error_ci;
362 }
363
364 ret = -ENOMEM;
365 req = skcipher_request_alloc(tfm, GFP_NOFS);
366 if (!req)
367 goto error_ci;
368
369 skcipher_request_set_sync_tfm(req, ci);
370 skcipher_request_set_callback(req, 0, NULL, NULL);
371
372 /* If the length is so short that the CTS algorithm will refuse to
373 * handle it, prepend a predictable block on the front and discard the
374 * output. Since CTS does draw data backwards, we can regenerate the
375 * encryption on just that block at decryption time.
376 */
377 if (len < 16) {
378 unsigned int i;
379 u8 *p = buf + 16;
380
381 kdebug("preblock %16phN", iv);
382 sha256_init(sha);
383 sha256_update(sha, iv, 32); /* iv and session key */
384 sha256_final(sha, b0);
385 kdebug("preblock %16phN", b0);
386
387 netfs_dump_sg("SRC", source_sg, n_source);
388 if (sg_copy_to_buffer(source_sg, n_source, p, len) != len) {
389 ret = -EIO;
390 goto error_req;
391 }
392
393 for (i = 0; i < len; i++)
394 p[i] += b0[i];
395
396 if (sg_copy_from_buffer(dest_sg, n_dest, p, len) != len) {
397 ret = -EIO;
398 goto error_req;
399 }
400 netfs_dump_sg("DST", source_sg, n_source);
401 ret = 0;
402 } else {
403 netfs_dump_sg("SRC", source_sg, n_source);
404 netfs_dump_sg("DST", dest_sg, n_dest);
405 skcipher_request_set_crypt(req, source_sg, dest_sg, len, iv);
406 ret = crypto_skcipher_encrypt(req);
407 if (ret < 0)
408 pr_err("Encrypt failed: %d\n", ret);
409 }
410
411 error_req:
412 skcipher_request_free(req);
413 error_ci:
414 kfree(buf);
415 crypto_free_sync_skcipher(ci);
416 error:
417 return ret;
418 }
419
--
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-04-05 13:31 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-05 13:31 [ammarfaizi2-block:dhowells/linux-fs/netfs-maple 39/40] fs/afs/write.c:347:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is true 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