linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Xiao Ni <xni@redhat.com>
To: mariusz.tkaczyk@linux.intel.com
Cc: ncroxon@redhat.com, linux-raid@vger.kernel.org
Subject: [PATCH 12/15] mdadm/super1: fix coverity issue CHECKED_RETURN
Date: Mon, 15 Jul 2024 15:36:01 +0800	[thread overview]
Message-ID: <20240715073604.30307-13-xni@redhat.com> (raw)
In-Reply-To: <20240715073604.30307-1-xni@redhat.com>

Signed-off-by: Xiao Ni <xni@redhat.com>
---
 super1.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/super1.c b/super1.c
index 81d29a652f36..4e4c7bfd15ae 100644
--- a/super1.c
+++ b/super1.c
@@ -260,7 +260,10 @@ static int aread(struct align_fd *afd, void *buf, int len)
 	n = read(afd->fd, b, iosize);
 	if (n <= 0)
 		return n;
-	lseek(afd->fd, len - n, 1);
+	if (lseek(afd->fd, len - n, 1) < 0) {
+		pr_err("lseek fails\n");
+		return -1;
+	}
 	if (n > len)
 		n = len;
 	memcpy(buf, b, n);
@@ -294,14 +297,20 @@ static int awrite(struct align_fd *afd, void *buf, int len)
 		n = read(afd->fd, b, iosize);
 		if (n <= 0)
 			return n;
-		lseek(afd->fd, -n, 1);
+		if (lseek(afd->fd, -n, 1) < 0) {
+			pr_err("lseek fails\n");
+			return -1;
+		}
 	}
 
 	memcpy(b, buf, len);
 	n = write(afd->fd, b, iosize);
 	if (n <= 0)
 		return n;
-	lseek(afd->fd, len - n, 1);
+	if (lseek(afd->fd, len - n, 1) < 0) {
+		pr_err("lseek fails\n");
+		return -1;
+	}
 	return len;
 }
 
@@ -2667,7 +2676,10 @@ static int locate_bitmap1(struct supertype *st, int fd, int node_num)
 	}
 	if (mustfree)
 		free(sb);
-	lseek64(fd, offset<<9, 0);
+	if (lseek64(fd, offset<<9, 0) < 0) {
+		pr_err("lseek fails\n");
+		ret = -1;
+	}
 	return ret;
 }
 
-- 
2.32.0 (Apple Git-132)


  parent reply	other threads:[~2024-07-15  7:36 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-15  7:35 [PATCH 00/15] mdadm: fix coverity issues Xiao Ni
2024-07-15  7:35 ` [PATCH 01/15] mdadm/Manage: 01r1fail cases fails Xiao Ni
2024-07-16 15:44   ` Mariusz Tkaczyk
2024-07-15  7:35 ` [PATCH 02/15] mdadm/Grow: fix coverity issue CHECKED_RETURN Xiao Ni
2024-07-17  9:33   ` Mariusz Tkaczyk
2024-07-18  2:29     ` Xiao Ni
2024-07-18  7:19       ` Mariusz Tkaczyk
2024-07-15  7:35 ` [PATCH 03/15] mdadm/Grow: fix coverity issue RESOURCE_LEAK Xiao Ni
2024-07-17 11:29   ` Mariusz Tkaczyk
2024-07-18  3:27     ` Xiao Ni
2024-07-19  9:52       ` Mariusz Tkaczyk
2024-07-15  7:35 ` [PATCH 04/15] mdadm/Grow: fix coverity issue STRING_OVERFLOW Xiao Ni
2024-07-15  7:35 ` [PATCH 05/15] mdadm/Incremental: fix coverity issues Xiao Ni
2024-07-15  7:35 ` [PATCH 06/15] mdadm/mdmon: fix coverity issue CHECKED_RETURN Xiao Ni
2024-07-15  7:35 ` [PATCH 07/15] mdadm/mdmon: fix coverity issue RESOURCE_LEAK Xiao Ni
2024-07-15  7:35 ` [PATCH 08/15] mdadm/mdopen: fix coverity issue CHECKED_RETURN Xiao Ni
2024-07-15  7:35 ` [PATCH 09/15] mdadm/mdopen: fix coverity issue STRING_OVERFLOW Xiao Ni
2024-07-15  7:35 ` [PATCH 10/15] mdadm/mdstat: fix coverity issue CHECKED_RETURN Xiao Ni
2024-07-15  7:36 ` [PATCH 11/15] mdadm/super0: fix coverity issue CHECKED_RETURN and EVALUATION_ORDER Xiao Ni
2024-07-15  7:36 ` Xiao Ni [this message]
2024-07-15  7:36 ` [PATCH 13/15] mdadm/super1: fix coverity issue DEADCODE Xiao Ni
2024-07-15  7:36 ` [PATCH 14/15] mdadm/super1: fix coverity issue EVALUATION_ORDER Xiao Ni
2024-07-15  7:36 ` [PATCH 15/15] mdadm/super1: fix coverity issue RESOURCE_LEAK Xiao Ni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240715073604.30307-13-xni@redhat.com \
    --to=xni@redhat.com \
    --cc=linux-raid@vger.kernel.org \
    --cc=mariusz.tkaczyk@linux.intel.com \
    --cc=ncroxon@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).