summaryrefslogtreecommitdiff
path: root/rust/helpers/pci.c
diff options
context:
space:
mode:
authorViacheslav Dubeyko <Slava.Dubeyko@ibm.com>2025-09-02 12:08:45 -0700
committerIlya Dryomov <idryomov@gmail.com>2025-10-08 23:30:47 +0200
commitc66120c84295a0495eb46dcfba829457acd6ef7d (patch)
tree0e99f320515747ef99de76b3e5abec9f2a059c59 /rust/helpers/pci.c
parent98a2850de49c10a1a09642e17978b925f95e6029 (diff)
ceph: cleanup in ceph_alloc_readdir_reply_buffer()
The Coverity Scan service has reported potential issue in ceph_alloc_readdir_reply_buffer() [1]. If order could be negative one, then it expects the issue in the logic: num_entries = (PAGE_SIZE << order) / size; Technically speaking, this logic [2] should prevent from making the order variable negative: if (!rinfo->dir_entries) return -ENOMEM; However, the allocation logic requires some cleanup. This patch makes sure that calculated bytes count will never exceed ULONG_MAX before get_order() calculation. And it adds the checking of order variable on negative value to guarantee that second half of the function's code will never operate by negative value of order variable even if something will be wrong or to be changed in the first half of the function's logic. v2 Alex Markuze suggested to add unlikely() macro for introduced condition checks. [1] https://scan5.scan.coverity.com/#/project-view/64304/10063?selectedIssue=1198252 [2] https://elixir.bootlin.com/linux/v6.17-rc3/source/fs/ceph/mds_client.c#L2553 Signed-off-by: Viacheslav Dubeyko <Slava.Dubeyko@ibm.com> Reviewed-by: Alex Markuze <amarkuze@redhat.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Diffstat (limited to 'rust/helpers/pci.c')
0 files changed, 0 insertions, 0 deletions