LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] bfs: prevent underflow in bfs_find_entry()
@ 2020-03-07  6:08 Dan Carpenter
  2020-03-09  8:40 ` AW: " Walter Harms
  2020-03-09  9:14 ` Tigran Aivazian
  0 siblings, 2 replies; 7+ messages in thread
From: Dan Carpenter @ 2020-03-07  6:08 UTC (permalink / raw)
  To: Tigran A. Aivazian; +Cc: linux-kernel, kernel-janitors

We check if "namelen" is larger than BFS_NAMELEN but we don't check
if it's less than zero so it causes a static checker.

    fs/bfs/dir.c:346 bfs_find_entry() warn: no lower bound on 'namelen'

It's nicer to make it unsigned anyway.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 fs/bfs/dir.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/bfs/dir.c b/fs/bfs/dir.c
index d8dfe3a0cb39..46a2663e5eb2 100644
--- a/fs/bfs/dir.c
+++ b/fs/bfs/dir.c
@@ -326,7 +326,7 @@ static struct buffer_head *bfs_find_entry(struct inode *dir,
 	struct buffer_head *bh = NULL;
 	struct bfs_dirent *de;
 	const unsigned char *name = child->name;
-	int namelen = child->len;
+	unsigned int namelen = child->len;
 
 	*res_dir = NULL;
 	if (namelen > BFS_NAMELEN)
-- 
2.11.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-03-10 18:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-07  6:08 [PATCH] bfs: prevent underflow in bfs_find_entry() Dan Carpenter
2020-03-09  8:40 ` AW: " Walter Harms
2020-03-10  9:06   ` Dan Carpenter
2020-03-10 17:57     ` AW: " Walter Harms
2020-03-10 18:22       ` Tigran Aivazian
2020-03-09  9:14 ` Tigran Aivazian
2020-03-10  8:38   ` Dan Carpenter

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).