From: Pavel Reichl <preichl@redhat.com>
To: linux-xfs@vger.kernel.org
Cc: cem@redhat.com
Subject: [PATCH 2/2] xfs_io: Fix do not loop through uninitialized var
Date: Fri, 31 May 2024 00:38:19 +0200 [thread overview]
Message-ID: <20240530223819.135697-3-preichl@redhat.com> (raw)
In-Reply-To: <20240530223819.135697-1-preichl@redhat.com>
Red Hat's covscan checker found the following issue:
xfsprogs-6.4.0/io/parent.c:115:2: var_decl: Declaring variable "count" without initializer.
xfsprogs-6.4.0/io/parent.c:134:2: uninit_use: Using uninitialized value "count".
Currently, jdm_parentpaths() returns EOPNOTSUPP and does not initialize
the count variable. The count variable is subsequently used in a for
loop, which leads to undefined behavior. Fix this by returning from the
check_parents() function immediately after checking the return value of
the jdm_parentpaths() function.
Signed-off-by: Pavel Reichl <preichl@redhat.com>
---
io/parent.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/io/parent.c b/io/parent.c
index 8f63607f..93f40997 100644
--- a/io/parent.c
+++ b/io/parent.c
@@ -112,7 +112,7 @@ check_parents(parent_t *parentbuf, size_t *parentbuf_size,
jdm_fshandle_t *fshandlep, struct xfs_bstat *statp)
{
int error, i;
- __u32 count;
+ __u32 count = 0;
parent_t *entryp;
do {
@@ -126,7 +126,7 @@ check_parents(parent_t *parentbuf, size_t *parentbuf_size,
(unsigned long long) statp->bs_ino,
strerror(errno));
err_status++;
- break;
+ return;
}
} while (error == ERANGE);
--
2.45.1
next prev parent reply other threads:[~2024-05-30 22:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-30 22:38 [PATCH 0/2] xfsprogs: Fix some issues found by checker Pavel Reichl
2024-05-30 22:38 ` [PATCH 1/2] xfs_db: Fix uninicialized error variable Pavel Reichl
2024-05-30 22:50 ` Darrick J. Wong
2024-05-31 7:49 ` Christoph Hellwig
2024-05-30 22:38 ` Pavel Reichl [this message]
2024-05-30 22:48 ` [PATCH 2/2] xfs_io: Fix do not loop through uninitialized var Darrick J. Wong
2024-05-31 9:12 ` Carlos Maiolino
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=20240530223819.135697-3-preichl@redhat.com \
--to=preichl@redhat.com \
--cc=cem@redhat.com \
--cc=linux-xfs@vger.kernel.org \
/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