]> git.ipfire.org Git - people/ms/linux.git/commit - fs/pstore/zone.c
pstore/zone: cleanup "rcnt" type
authorDan Carpenter <dan.carpenter@oracle.com>
Thu, 23 Jun 2022 13:40:13 +0000 (16:40 +0300)
committerKees Cook <keescook@chromium.org>
Thu, 23 Jun 2022 15:27:52 +0000 (08:27 -0700)
commit2c09d1443b9b8b6e25bfb2acf51ad442cf9b314e
tree109eb872bf688d144edcd667996662ee9ed5a0a7
parente4f0a7ec586b7644107839f5394fb685cf1aadcc
pstore/zone: cleanup "rcnt" type

The info->read() function returns ssize_t.  That means that info->read()
either returns either negative error codes or a positive number
representing the bytes read.

The "rcnt" variable should be declared as ssize_t as well.  Most places
do this correctly but psz_kmsg_recover_meta() needed to be fixed.

This code casts the "rcnt" to int.  That is unnecessary when "rcnt"
is already signed.  It's also slightly wrong because if info->read()
returned a very high (more than INT_MAX) number of bytes then this might
treat that as an error.  This bug cannot happen in real life, so it
doesn't affect run time, but static checkers correctly complain that it
is wrong.

fs/pstore/zone.c:366 psz_kmsg_recover_data() warn: casting 'rcnt' truncates high bits

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/YrRtPSFHDVJzV6d+@kili
fs/pstore/zone.c