]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
rbd: make coverity happy 957/head
authorIlya Dryomov <ilya.dryomov@inktank.com>
Tue, 17 Dec 2013 15:42:30 +0000 (17:42 +0200)
committerIlya Dryomov <ilya.dryomov@inktank.com>
Tue, 17 Dec 2013 15:42:30 +0000 (17:42 +0200)
commit0edbda204bc125e6b59753f4f895473f89bf0ba0
tree4d580a5baeeb1ee216c43f905e83fad7eef58b11
parent1597d4e9f57758c80d8124510ff8b54199d124ad
rbd: make coverity happy

A recent coverity run found two "defects" in rbd.cc:

** CID 1138367:  Time of check time of use  (TOCTOU)
/rbd.cc: 2024 in do_kernel_rm(const char *)()

2019   const char *fname = "/sys/bus/rbd/remove_single_major";
2020   if (stat(fname, &sbuf)) {
2021     fname = "/sys/bus/rbd/remove";
2022   }
2023
2024   int fd = open(fname, O_WRONLY);
2025   if (fd < 0) {

** CID 1138368:  Time of check time of use  (TOCTOU)
/rbd.cc: 1735 in do_kernel_add(const char *, const char *, const char *)()

same as above, s/remove/add

There is nothing racey going on here, and this is not an instance of
TOCTOU, but, instead of silencing coverity with annotatations, redo
this with two open() calls.

Signed-off-by: Ilya Dryomov <ilya.dryomov@inktank.com>
src/rbd.cc