[PATCH] fs: afs: Fix uninit 'count' in afs_deliver_fs_get_capabilities
SurajSonawane2415
surajsonawane0215 at gmail.com
Wed Oct 9 11:35:19 PDT 2024
From: Suraj Sonawane <surajsonawane0215 at gmail.com>
Fix the uninitialized symbol 'count' in the function
afs_deliver_fs_get_capabilities to resolve the error generated
with the smatch tool:
fs/afs/fsclient.c:1704 afs_deliver_fs_get_capabilities() error:
uninitialized symbol 'count'.
The error regarding the uninitialized count symbol in the
afs_deliver_fs_get_capabilities function arises due to the
control flow of the switch statement. Ensure that you
initialize count before its usage to avoid undefined behavior.
If unmarshall skips to cases 2 or 3, count remains
uninitialized and may contain a garbage value. This could lead
to errors flagged by static analysis tools like smatch.
By initializing count to zero, guarantee that it has a defined
value regardless of the control path taken, thereby enhancing
code reliability and preventing potential issues associated
with uninitialized variables.
Signed-off-by: Suraj Sonawane <surajsonawane0215 at gmail.com>
---
fs/afs/fsclient.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/afs/fsclient.c b/fs/afs/fsclient.c
index 098fa034a..4ab41dcdb 100644
--- a/fs/afs/fsclient.c
+++ b/fs/afs/fsclient.c
@@ -1665,7 +1665,7 @@ int afs_fs_give_up_all_callbacks(struct afs_net *net, struct afs_server *server,
*/
static int afs_deliver_fs_get_capabilities(struct afs_call *call)
{
- u32 count;
+ u32 count = 0;
int ret;
_enter("{%u,%zu}", call->unmarshall, iov_iter_count(call->iter));
--
2.34.1
More information about the linux-afs
mailing list