]> git.baikalelectronics.ru Git - kernel.git/commit
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)
commit8bb918364da8d3f301d98c83ae0fcd7e1d4045c5
tree109eb872bf688d144edcd667996662ee9ed5a0a7
parent05ba8240bcb6636bf672a69a21f2818db98ca71f
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