From patchwork Fri Jul 10 20:36:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Mayhew X-Patchwork-Id: 11657383 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B323213B6 for ; Fri, 10 Jul 2020 20:37:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 90831207BB for ; Fri, 10 Jul 2020 20:37:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="SnxTvh6A" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726725AbgGJUhF (ORCPT ); Fri, 10 Jul 2020 16:37:05 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:46482 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727819AbgGJUhF (ORCPT ); Fri, 10 Jul 2020 16:37:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594413423; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3Bd+5oT+q5+zV+4nbqO+g2MuR9O4uN8iXdTW3R18cuA=; b=SnxTvh6AfAs98DlHNlGrxxfQaWDBeCSofDoL2EHlrY674y9M8coPUdGhASTZ4CEt16stiW LQ3JfrXLHBBsdIDmhMejmD+KNhJGXy59wGXdsZDlncA0DkuWlWHnZXvAHG59wxX/KoZd/7 +6Tyr8ccQe6ZryFNJ8SHB8w+BwY0y2Q= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-431-SHXXqZF1NbCXwMnnFQctZw-1; Fri, 10 Jul 2020 16:37:02 -0400 X-MC-Unique: SHXXqZF1NbCXwMnnFQctZw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4E59D100AA22 for ; Fri, 10 Jul 2020 20:37:01 +0000 (UTC) Received: from aion.usersys.redhat.com (ovpn-113-242.rdu2.redhat.com [10.10.113.242]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 32B646FEFB; Fri, 10 Jul 2020 20:37:01 +0000 (UTC) Received: by aion.usersys.redhat.com (Postfix, from userid 1000) id 60AD31A01B8; Fri, 10 Jul 2020 16:37:00 -0400 (EDT) From: Scott Mayhew To: steved@redhat.com Cc: linux-nfs@vger.kernel.org Subject: [nfs-utils PATCH 1/5] nfsdcld: Fix a few Coverity Scan RESOURCE_LEAK errors Date: Fri, 10 Jul 2020 16:36:56 -0400 Message-Id: <20200710203700.2546112-2-smayhew@redhat.com> In-Reply-To: <20200710203700.2546112-1-smayhew@redhat.com> References: <20200710203700.2546112-1-smayhew@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Scott Mayhew --- utils/nfsdcld/legacy.c | 2 ++ utils/nfsdcld/nfsdcld.c | 1 + utils/nfsdcld/sqlite.c | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/utils/nfsdcld/legacy.c b/utils/nfsdcld/legacy.c index 3c6bea6..b8ea4ff 100644 --- a/utils/nfsdcld/legacy.c +++ b/utils/nfsdcld/legacy.c @@ -60,6 +60,7 @@ legacy_load_clients_from_recdir(int *num_records) } if (read(fd, recdirname, PATH_MAX) < 0) { xlog(D_GENERAL, "Unable to read from %s: %m", NFSD_RECDIR_FILE); + close(fd); return; } close(fd); @@ -135,6 +136,7 @@ legacy_clear_recdir(void) } if (read(fd, recdirname, PATH_MAX) < 0) { xlog(D_GENERAL, "Unable to read from %s: %m", NFSD_RECDIR_FILE); + close(fd); return; } close(fd); diff --git a/utils/nfsdcld/nfsdcld.c b/utils/nfsdcld/nfsdcld.c index be65562..bb8e365 100644 --- a/utils/nfsdcld/nfsdcld.c +++ b/utils/nfsdcld/nfsdcld.c @@ -331,6 +331,7 @@ cld_check_grace_period(void) if (read(fd, &c, 1) < 0) { xlog(L_WARNING, "Unable to read from %s: %m", NFSD_END_GRACE_FILE); + close(fd); return 1; } close(fd); diff --git a/utils/nfsdcld/sqlite.c b/utils/nfsdcld/sqlite.c index 6666c86..e61e67c 100644 --- a/utils/nfsdcld/sqlite.c +++ b/utils/nfsdcld/sqlite.c @@ -380,7 +380,7 @@ sqlite_maindb_init_v4(void) &err); if (ret != SQLITE_OK) { xlog(L_ERROR, "Unable to begin transaction: %s", err); - return ret; + goto out; } /* From patchwork Fri Jul 10 20:36:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Mayhew X-Patchwork-Id: 11657387 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 80649913 for ; Fri, 10 Jul 2020 20:37:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 678452078B for ; Fri, 10 Jul 2020 20:37:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="CAbpOjh+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728003AbgGJUhG (ORCPT ); Fri, 10 Jul 2020 16:37:06 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:42672 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727840AbgGJUhF (ORCPT ); Fri, 10 Jul 2020 16:37:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594413424; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uGBjYBBnrmlbW76UC/Zf/TpBSoipVj9Ds1NUss7ASjM=; b=CAbpOjh+YN3lE3TadSGLQjkFkQmm9x9h22U5fMSFY0ZtYVci5+k4f+R8RFTeH8Lxv4/fsA +NGnZL+0/QMaAZLVBUmaiJbUmYLUslklfgRlRO9WQbD7JRla0nckV0FZT6muXGrCZk5uGr dHDhc7U2wz0DKcbHRNy/ffrMdMWxm1w= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-12-Gsv9TsmXOJuYUNuvuPGekQ-1; Fri, 10 Jul 2020 16:37:02 -0400 X-MC-Unique: Gsv9TsmXOJuYUNuvuPGekQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 32D3D800597 for ; Fri, 10 Jul 2020 20:37:01 +0000 (UTC) Received: from aion.usersys.redhat.com (ovpn-113-242.rdu2.redhat.com [10.10.113.242]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1956B7EF92; Fri, 10 Jul 2020 20:37:01 +0000 (UTC) Received: by aion.usersys.redhat.com (Postfix, from userid 1000) id 67B3B1A0254; Fri, 10 Jul 2020 16:37:00 -0400 (EDT) From: Scott Mayhew To: steved@redhat.com Cc: linux-nfs@vger.kernel.org Subject: [nfs-utils PATCH 2/5] nfsdcld: Fix a few Coverity Scan TOCTOU errors Date: Fri, 10 Jul 2020 16:36:57 -0400 Message-Id: <20200710203700.2546112-3-smayhew@redhat.com> In-Reply-To: <20200710203700.2546112-1-smayhew@redhat.com> References: <20200710203700.2546112-1-smayhew@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Calling stat() on recdirname so that we can see if it's a directory is unnecessary anyways, since opendir() will report an error if it's not. Signed-off-by: Scott Mayhew --- utils/nfsdcld/legacy.c | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/utils/nfsdcld/legacy.c b/utils/nfsdcld/legacy.c index b8ea4ff..1fb74d4 100644 --- a/utils/nfsdcld/legacy.c +++ b/utils/nfsdcld/legacy.c @@ -50,7 +50,6 @@ legacy_load_clients_from_recdir(int *num_records) struct dirent *entry; char recdirname[PATH_MAX]; char buf[NFS4_OPAQUE_LIMIT]; - struct stat st; char *nl; fd = open(NFSD_RECDIR_FILE, O_RDONLY); @@ -69,15 +68,6 @@ legacy_load_clients_from_recdir(int *num_records) if (!nl) return; *nl = '\0'; - if (stat(recdirname, &st) < 0) { - xlog(D_GENERAL, "Unable to stat %s: %d", recdirname, errno); - return; - } - if (!S_ISDIR(st.st_mode)) { - xlog(D_GENERAL, "%s is not a directory: mode=0%o", recdirname - , st.st_mode); - return; - } v4recovery = opendir(recdirname); if (!v4recovery) return; @@ -126,7 +116,6 @@ legacy_clear_recdir(void) struct dirent *entry; char recdirname[PATH_MAX]; char dirname[PATH_MAX]; - struct stat st; char *nl; fd = open(NFSD_RECDIR_FILE, O_RDONLY); @@ -145,15 +134,6 @@ legacy_clear_recdir(void) if (!nl) return; *nl = '\0'; - if (stat(recdirname, &st) < 0) { - xlog(D_GENERAL, "Unable to stat %s: %d", recdirname, errno); - return; - } - if (!S_ISDIR(st.st_mode)) { - xlog(D_GENERAL, "%s is not a directory: mode=0%o", recdirname - , st.st_mode); - return; - } v4recovery = opendir(recdirname); if (!v4recovery) return; From patchwork Fri Jul 10 20:36:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Mayhew X-Patchwork-Id: 11657385 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E05C514E3 for ; Fri, 10 Jul 2020 20:37:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BE82C2075D for ; Fri, 10 Jul 2020 20:37:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="NWGmU6Nx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727819AbgGJUhG (ORCPT ); Fri, 10 Jul 2020 16:37:06 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:47398 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728003AbgGJUhE (ORCPT ); Fri, 10 Jul 2020 16:37:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594413424; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=v2/NR4kk3V/5MSue4Jd/eO1ySNEoIzIaezmCb0xLGuU=; b=NWGmU6NxW9hE8RH0MnseVMj4DP/4LjEmDaePWgq3ScB7zDv00dWv4geXR7NWw2ati7pGj2 dcLNKmM3ChPIuFEGIf5uRqmMiRWsPMisnT/l/dCMwZFFD4lhY2E2mLyGbzZpHXXiqZr5Tk sKwKx2r/36sU2TUvD/ilIN0eI5yWGPQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-262-xtKjjtEnML-8d7G1NT7BVw-1; Fri, 10 Jul 2020 16:37:02 -0400 X-MC-Unique: xtKjjtEnML-8d7G1NT7BVw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 33DE41B18BC0 for ; Fri, 10 Jul 2020 20:37:01 +0000 (UTC) Received: from aion.usersys.redhat.com (ovpn-113-242.rdu2.redhat.com [10.10.113.242]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1949A6FEC2; Fri, 10 Jul 2020 20:37:01 +0000 (UTC) Received: by aion.usersys.redhat.com (Postfix, from userid 1000) id 6B8401A0257; Fri, 10 Jul 2020 16:37:00 -0400 (EDT) From: Scott Mayhew To: steved@redhat.com Cc: linux-nfs@vger.kernel.org Subject: [nfs-utils PATCH 3/5] nfsdcld: Fix a few Coverity Scan STRING_NULL errors Date: Fri, 10 Jul 2020 16:36:58 -0400 Message-Id: <20200710203700.2546112-4-smayhew@redhat.com> In-Reply-To: <20200710203700.2546112-1-smayhew@redhat.com> References: <20200710203700.2546112-1-smayhew@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Scott Mayhew --- utils/nfsdcld/legacy.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/utils/nfsdcld/legacy.c b/utils/nfsdcld/legacy.c index 1fb74d4..9e9f758 100644 --- a/utils/nfsdcld/legacy.c +++ b/utils/nfsdcld/legacy.c @@ -48,7 +48,7 @@ legacy_load_clients_from_recdir(int *num_records) int fd; DIR *v4recovery; struct dirent *entry; - char recdirname[PATH_MAX]; + char recdirname[PATH_MAX+1]; char buf[NFS4_OPAQUE_LIMIT]; char *nl; @@ -64,6 +64,7 @@ legacy_load_clients_from_recdir(int *num_records) } close(fd); /* the output from the proc file isn't null-terminated */ + recdirname[PATH_MAX] = '\0'; nl = strchr(recdirname, '\n'); if (!nl) return; @@ -114,7 +115,7 @@ legacy_clear_recdir(void) int fd; DIR *v4recovery; struct dirent *entry; - char recdirname[PATH_MAX]; + char recdirname[PATH_MAX+1]; char dirname[PATH_MAX]; char *nl; @@ -130,6 +131,7 @@ legacy_clear_recdir(void) } close(fd); /* the output from the proc file isn't null-terminated */ + recdirname[PATH_MAX] = '\0'; nl = strchr(recdirname, '\n'); if (!nl) return; From patchwork Fri Jul 10 20:36:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Mayhew X-Patchwork-Id: 11657381 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 80B8514DD for ; Fri, 10 Jul 2020 20:37:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5ED1E2078B for ; Fri, 10 Jul 2020 20:37:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Lf6WHgKW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727820AbgGJUhF (ORCPT ); Fri, 10 Jul 2020 16:37:05 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:47573 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726725AbgGJUhE (ORCPT ); Fri, 10 Jul 2020 16:37:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594413423; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2SzHac3Ct3/Ey8/0VOkLkyClJK2CehQmPHYM2FvcU3Q=; b=Lf6WHgKWR/MOwp1GkJEtnX56tx70w/70zxOU/zjDC8G3aM1dkvZ+ZbmXsxxHQLMQXiGCoP nkeUQ0pRFwa6bCMyPVRl28x0OH2Y91Df9osXDZbzShxh/A3vqM8BOj/nzpk9G9UyJ8iXXB NZNWcaYTuJerEAp8+/Chs3SBQ9Rih8s= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-29-GpwdaCizNT2UhuF09mwfyQ-1; Fri, 10 Jul 2020 16:37:02 -0400 X-MC-Unique: GpwdaCizNT2UhuF09mwfyQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4B718100A68E for ; Fri, 10 Jul 2020 20:37:01 +0000 (UTC) Received: from aion.usersys.redhat.com (ovpn-113-242.rdu2.redhat.com [10.10.113.242]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2F91210013C4; Fri, 10 Jul 2020 20:37:01 +0000 (UTC) Received: by aion.usersys.redhat.com (Postfix, from userid 1000) id 6F4861A025A; Fri, 10 Jul 2020 16:37:00 -0400 (EDT) From: Scott Mayhew To: steved@redhat.com Cc: linux-nfs@vger.kernel.org Subject: [nfs-utils PATCH 4/5] nfsdcld: Fix a few Coverity Scan CLANG_WARNING errors Date: Fri, 10 Jul 2020 16:36:59 -0400 Message-Id: <20200710203700.2546112-5-smayhew@redhat.com> In-Reply-To: <20200710203700.2546112-1-smayhew@redhat.com> References: <20200710203700.2546112-1-smayhew@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Scott Mayhew --- utils/nfsdcld/nfsdcld.c | 6 ++++-- utils/nfsdcld/sqlite.c | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/utils/nfsdcld/nfsdcld.c b/utils/nfsdcld/nfsdcld.c index bb8e365..9b6d2c3 100644 --- a/utils/nfsdcld/nfsdcld.c +++ b/utils/nfsdcld/nfsdcld.c @@ -252,11 +252,12 @@ cld_inotify_setup(void) xlog_err("%s: inotify_add_watch failed: %m", __func__); ret = -errno; goto out_err; - } + } else + ret = 0; out_free: free(dirc); - return 0; + return ret; out_err: close(inotify_fd); goto out_free; @@ -796,6 +797,7 @@ main(int argc, char **argv) break; default: usage(progname); + free(progname); return 0; } } diff --git a/utils/nfsdcld/sqlite.c b/utils/nfsdcld/sqlite.c index e61e67c..ef11a54 100644 --- a/utils/nfsdcld/sqlite.c +++ b/utils/nfsdcld/sqlite.c @@ -831,7 +831,6 @@ sqlite_prepare_dbh(const char *topdir) switch (ret) { case CLD_SQLITE_LATEST_SCHEMA_VERSION: /* DB is already set up. Do nothing */ - ret = 0; break; case 3: /* Old DB -- update to new schema */ @@ -868,6 +867,8 @@ sqlite_prepare_dbh(const char *topdir) } ret = sqlite_startup_query_grace(); + if (ret) + goto out_close; ret = sqlite_query_first_time(&first_time); if (ret) From patchwork Fri Jul 10 20:37:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Mayhew X-Patchwork-Id: 11657389 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1A27214DD for ; Fri, 10 Jul 2020 20:37:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EC11D2075D for ; Fri, 10 Jul 2020 20:37:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="dTa+ASxZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727840AbgGJUhG (ORCPT ); Fri, 10 Jul 2020 16:37:06 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:56444 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727086AbgGJUhF (ORCPT ); Fri, 10 Jul 2020 16:37:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594413424; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GgT+smPK8ydn2uvNuNUXCThlyQSoQQBLBX5YcnJnuKA=; b=dTa+ASxZauGIDB0nSYuYwmcoxFwlmF3uT+V5LhPVrBaBwblOyc+C7bn9eKlPKwqmyUWoJt rD41ebihlE4McRRUW1jpSHmQ4GMat0LUmxirvcAdySvkBIqwE5Qa0a5HmM7N4YW4xpzJuV Sb4NHMmI7tz33jkkARA67aC76kfks3E= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-37-gVVs3nUAM6GU0ErWAU4lRg-1; Fri, 10 Jul 2020 16:37:03 -0400 X-MC-Unique: gVVs3nUAM6GU0ErWAU4lRg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 244AB100AA23 for ; Fri, 10 Jul 2020 20:37:02 +0000 (UTC) Received: from aion.usersys.redhat.com (ovpn-113-242.rdu2.redhat.com [10.10.113.242]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 012467EF8F; Fri, 10 Jul 2020 20:37:01 +0000 (UTC) Received: by aion.usersys.redhat.com (Postfix, from userid 1000) id 729201A025E; Fri, 10 Jul 2020 16:37:00 -0400 (EDT) From: Scott Mayhew To: steved@redhat.com Cc: linux-nfs@vger.kernel.org Subject: [nfs-utils PATCH 5/5] nfsdcld: Fix a few Coverity Scan CHECKED_RETURN errors. Date: Fri, 10 Jul 2020 16:37:00 -0400 Message-Id: <20200710203700.2546112-6-smayhew@redhat.com> In-Reply-To: <20200710203700.2546112-1-smayhew@redhat.com> References: <20200710203700.2546112-1-smayhew@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Scott Mayhew --- utils/nfsdcld/legacy.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/utils/nfsdcld/legacy.c b/utils/nfsdcld/legacy.c index 9e9f758..b89374c 100644 --- a/utils/nfsdcld/legacy.c +++ b/utils/nfsdcld/legacy.c @@ -51,18 +51,19 @@ legacy_load_clients_from_recdir(int *num_records) char recdirname[PATH_MAX+1]; char buf[NFS4_OPAQUE_LIMIT]; char *nl; + ssize_t n; fd = open(NFSD_RECDIR_FILE, O_RDONLY); if (fd < 0) { xlog(D_GENERAL, "Unable to open %s: %m", NFSD_RECDIR_FILE); return; } - if (read(fd, recdirname, PATH_MAX) < 0) { + n = read(fd, recdirname, PATH_MAX); + close(fd); + if (n < 0) { xlog(D_GENERAL, "Unable to read from %s: %m", NFSD_RECDIR_FILE); - close(fd); return; } - close(fd); /* the output from the proc file isn't null-terminated */ recdirname[PATH_MAX] = '\0'; nl = strchr(recdirname, '\n'); @@ -118,18 +119,19 @@ legacy_clear_recdir(void) char recdirname[PATH_MAX+1]; char dirname[PATH_MAX]; char *nl; + ssize_t n; fd = open(NFSD_RECDIR_FILE, O_RDONLY); if (fd < 0) { xlog(D_GENERAL, "Unable to open %s: %m", NFSD_RECDIR_FILE); return; } - if (read(fd, recdirname, PATH_MAX) < 0) { + n = read(fd, recdirname, PATH_MAX); + close(fd); + if (n < 0) { xlog(D_GENERAL, "Unable to read from %s: %m", NFSD_RECDIR_FILE); - close(fd); return; } - close(fd); /* the output from the proc file isn't null-terminated */ recdirname[PATH_MAX] = '\0'; nl = strchr(recdirname, '\n');