coverity: get_service_fd() is passed to a parameter that cannot be negative

criu/fdstore.c:110: negative_return_fn: Function "get_service_fd(FDSTORE_SK_OFF)" returns a negative number.
criu/fdstore.c:110: assign: Assigning: "sk" = "get_service_fd(FDSTORE_SK_OFF)".
criu/fdstore.c:114: negative_returns: "sk" is passed to a parameter that cannot be negative.

criu/namespaces.c:1366: negative_return_fn: Function "get_service_fd(USERNSD_SK)" returns a negative number.
criu/namespaces.c:1366: assign: Assigning: "sk" = "get_service_fd(USERNSD_SK)".
criu/namespaces.c:1389: negative_returns: "sk" is passed to a parameter that cannot be negative.

Signed-off-by: Adrian Reber <areber@redhat.com>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
This commit is contained in:
Adrian Reber 2020-10-14 08:29:13 +00:00 committed by Andrei Vagin
parent 6ff51fd8d3
commit c405a01166
2 changed files with 11 additions and 2 deletions

View file

@ -107,8 +107,13 @@ int fdstore_add(int fd)
int fdstore_get(int id)
{
int sk = get_service_fd(FDSTORE_SK_OFF);
int fd;
int sk, fd;
sk = get_service_fd(FDSTORE_SK_OFF);
if (sk < 0) {
pr_err("Cannot get FDSTORE_SK_OFF fd\n");
return -1;
}
mutex_lock(&desc->lock);
if (setsockopt(sk, SOL_SOCKET, SO_PEEK_OFF, &id, sizeof(id))) {

View file

@ -1364,6 +1364,10 @@ int __userns_call(const char *func_name, uns_call_t call, int flags,
return call(arg, fd, getpid());
sk = get_service_fd(USERNSD_SK);
if (sk < 0) {
pr_err("Cannot get USERNSD_SK fd\n");
return -1;
}
pr_debug("uns: calling %s (%d, %x)\n", func_name, fd, flags);
if (!async)