2008-06-30 16:59:57

by Benny Halevy

[permalink] [raw]
Subject: [PATCH] dlm: fix uninitialized variable for search_rsb_list callers

gcc 4.3.0 correctly emits the following warning.
search_rsb_list does not *r_ret if no dlm_rsb is found
and _search_rsb may pass the uninitialized value upstream
on the error path when both calls to search_rsb_list
return non-zero error.

The fix sets *r_ret to NULL on search_rsb_list's not-found path.

/usr0/export/dev/bhalevy/git/linux-pnfs-bh-nfs41/fs/dlm/lock.c: In function ‘_search_rsb’:
/usr0/export/dev/bhalevy/git/linux-pnfs-bh-nfs41/fs/dlm/lock.c:378: warning: ‘r’ may be used uninitialized in this function

Signed-off-by: Benny Halevy <[email protected]>
---
fs/dlm/lock.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c
index 2d3d102..79c1d65 100644
--- a/fs/dlm/lock.c
+++ b/fs/dlm/lock.c
@@ -363,6 +363,7 @@ static int search_rsb_list(struct list_head *head, char *name, int len,
if (len == r->res_length && !memcmp(name, r->res_name, len))
goto found;
}
+ *r_ret = NULL;
return -EBADR;

found:
--
1.5.6.GIT


2008-06-30 17:06:37

by David Teigland

[permalink] [raw]
Subject: Re: [PATCH] dlm: fix uninitialized variable for search_rsb_list callers

On Mon, Jun 30, 2008 at 07:59:14PM +0300, Benny Halevy wrote:
> gcc 4.3.0 correctly emits the following warning.
> search_rsb_list does not *r_ret if no dlm_rsb is found
> and _search_rsb may pass the uninitialized value upstream
> on the error path when both calls to search_rsb_list
> return non-zero error.
>
> The fix sets *r_ret to NULL on search_rsb_list's not-found path.

Added to dlm.git.
Thanks, Dave