* [PATCH]initialize the array of fs/ncpfs/inode.c
@ 2011-04-10 10:08 Harry Wei
2011-04-11 23:18 ` Andrew Morton
0 siblings, 1 reply; 4+ messages in thread
From: Harry Wei @ 2011-04-10 10:08 UTC (permalink / raw)
To: petr, viro, arnd, npiggin, jens.axboe, greg, akpm, joe; +Cc: linux-kernel
Hi us,
When i compile the linux-2.6.38.2, some warnings happened
to me. One of them is like following.
fs/ncpfs/inode.c: In function 'ncp_fill_super':
fs/ncpfs/inode.c:451: warning: 'data.mounted_vol[1u]' may be used
uninitialized in this function
...
See details by the URL:
http://s1202.photobucket.com/albums/bb364/harrywei/Kernel/?action=view¤t=patched.png
So i patch for it below.
Thanks.
Harry Wei.
From: Harry Wei <harryxiyou@gmail.com>
Signed-off-by: Harry Wei <harryxiyou@gmail.com>
---
fs/ncpfs/inode.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c
index 00a1d1c..15f0ebb 100644
--- a/fs/ncpfs/inode.c
+++ b/fs/ncpfs/inode.c
@@ -30,6 +30,7 @@
#include <linux/mount.h>
#include <linux/seq_file.h>
#include <linux/namei.h>
+#include <linux/ncp.h>
#include <net/sock.h>
@@ -461,6 +462,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
#endif
struct ncp_entry_info finfo;
+ data.mounted_vol[NCP_VOLNAME_LEN + 1] = {0};
data.wdog_pid = NULL;
server = kzalloc(sizeof(struct ncp_server), GFP_KERNEL);
if (!server)
--
1.7.0.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH]initialize the array of fs/ncpfs/inode.c
2011-04-10 10:08 [PATCH]initialize the array of fs/ncpfs/inode.c Harry Wei
@ 2011-04-11 23:18 ` Andrew Morton
2011-04-11 23:28 ` Tim Gardner
2011-04-12 3:17 ` Harry Wei
0 siblings, 2 replies; 4+ messages in thread
From: Andrew Morton @ 2011-04-11 23:18 UTC (permalink / raw)
To: Harry Wei; +Cc: petr, viro, arnd, npiggin, jens.axboe, greg, joe, linux-kernel
On Sun, 10 Apr 2011 18:08:18 +0800
Harry Wei <jiaweiwei.xiyou@gmail.com> wrote:
> Hi us,
> When i compile the linux-2.6.38.2, some warnings happened
> to me. One of them is like following.
>
> fs/ncpfs/inode.c: In function 'ncp_fill_super':
> fs/ncpfs/inode.c:451: warning: 'data.mounted_vol[1u]' may be used
> uninitialized in this function
> ...
> See details by the URL:
> http://s1202.photobucket.com/albums/bb364/harrywei/Kernel/?action=view¤t=patched.png
Yup. The compiler is "wrong" because it doesn't know that the
uninitialised bytes will never be read, because they fall after the
'\0' in a null-terminated string.
> @@ -461,6 +462,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
> #endif
> struct ncp_entry_info finfo;
>
> + data.mounted_vol[NCP_VOLNAME_LEN + 1] = {0};
> data.wdog_pid = NULL;
> server = kzalloc(sizeof(struct ncp_server), GFP_KERNEL);
> if (!server)
hm. I'm not sure that this fixed data.mounted_vol[2u],
data.mounted_vol[3u], etc.
How about we use the big hammer?
From: Andrew Morton <akpm@linux-foundation.org>
fs/ncpfs/inode.c: In function 'ncp_fill_super':
fs/ncpfs/inode.c:451: warning: 'data.mounted_vol[1u]' may be used uninitialized in this function
fs/ncpfs/inode.c:451: warning: 'data.mounted_vol[2u]' may be used uninitialized in this function
fs/ncpfs/inode.c:451: warning: 'data.mounted_vol[3u]' may be used uninitialized in this function
...
It's notabug, but we can easily fix it with a memset().
Reported-by: Harry Wei <jiaweiwei.xiyou@gmail.com>
Cc: Petr Vandrovec <petr@vandrovec.name>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
fs/ncpfs/inode.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff -puN fs/ncpfs/inode.c~fs-ncpfs-inodec-suppress-used-uninitialised-warning fs/ncpfs/inode.c
--- a/fs/ncpfs/inode.c~fs-ncpfs-inodec-suppress-used-uninitialised-warning
+++ a/fs/ncpfs/inode.c
@@ -461,7 +461,7 @@ static int ncp_fill_super(struct super_b
#endif
struct ncp_entry_info finfo;
- data.wdog_pid = NULL;
+ memset(data, 0, sizeof(data));
server = kzalloc(sizeof(struct ncp_server), GFP_KERNEL);
if (!server)
return -ENOMEM;
@@ -496,7 +496,6 @@ static int ncp_fill_super(struct super_b
struct ncp_mount_data_v4* md = (struct ncp_mount_data_v4*)raw_data;
data.flags = md->flags;
- data.int_flags = 0;
data.mounted_uid = md->mounted_uid;
data.wdog_pid = find_get_pid(md->wdog_pid);
data.ncp_fd = md->ncp_fd;
@@ -507,7 +506,6 @@ static int ncp_fill_super(struct super_b
data.file_mode = md->file_mode;
data.dir_mode = md->dir_mode;
data.info_fd = -1;
- data.mounted_vol[0] = 0;
}
break;
default:
_
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH]initialize the array of fs/ncpfs/inode.c
2011-04-11 23:18 ` Andrew Morton
@ 2011-04-11 23:28 ` Tim Gardner
2011-04-12 3:17 ` Harry Wei
1 sibling, 0 replies; 4+ messages in thread
From: Tim Gardner @ 2011-04-11 23:28 UTC (permalink / raw)
To: Andrew Morton
Cc: Harry Wei, petr, viro, arnd, npiggin, jens.axboe, greg, joe,
linux-kernel
On 04/11/2011 04:18 PM, Andrew Morton wrote:
> On Sun, 10 Apr 2011 18:08:18 +0800
> Harry Wei<jiaweiwei.xiyou@gmail.com> wrote:
>
>> Hi us,
>> When i compile the linux-2.6.38.2, some warnings happened
>> to me. One of them is like following.
>>
>> fs/ncpfs/inode.c: In function 'ncp_fill_super':
>> fs/ncpfs/inode.c:451: warning: 'data.mounted_vol[1u]' may be used
>> uninitialized in this function
>> ...
>> See details by the URL:
>> http://s1202.photobucket.com/albums/bb364/harrywei/Kernel/?action=view¤t=patched.png
>
> Yup. The compiler is "wrong" because it doesn't know that the
> uninitialised bytes will never be read, because they fall after the
> '\0' in a null-terminated string.
>
>> @@ -461,6 +462,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
>> #endif
>> struct ncp_entry_info finfo;
>>
>> + data.mounted_vol[NCP_VOLNAME_LEN + 1] = {0};
>> data.wdog_pid = NULL;
>> server = kzalloc(sizeof(struct ncp_server), GFP_KERNEL);
>> if (!server)
>
> hm. I'm not sure that this fixed data.mounted_vol[2u],
> data.mounted_vol[3u], etc.
>
> How about we use the big hammer?
>
>
>
> From: Andrew Morton<akpm@linux-foundation.org>
>
> fs/ncpfs/inode.c: In function 'ncp_fill_super':
> fs/ncpfs/inode.c:451: warning: 'data.mounted_vol[1u]' may be used uninitialized in this function
> fs/ncpfs/inode.c:451: warning: 'data.mounted_vol[2u]' may be used uninitialized in this function
> fs/ncpfs/inode.c:451: warning: 'data.mounted_vol[3u]' may be used uninitialized in this function
> ...
>
> It's notabug, but we can easily fix it with a memset().
>
> Reported-by: Harry Wei<jiaweiwei.xiyou@gmail.com>
> Cc: Petr Vandrovec<petr@vandrovec.name>
> Signed-off-by: Andrew Morton<akpm@linux-foundation.org>
> ---
>
> fs/ncpfs/inode.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff -puN fs/ncpfs/inode.c~fs-ncpfs-inodec-suppress-used-uninitialised-warning fs/ncpfs/inode.c
> --- a/fs/ncpfs/inode.c~fs-ncpfs-inodec-suppress-used-uninitialised-warning
> +++ a/fs/ncpfs/inode.c
> @@ -461,7 +461,7 @@ static int ncp_fill_super(struct super_b
> #endif
> struct ncp_entry_info finfo;
>
> - data.wdog_pid = NULL;
> + memset(data, 0, sizeof(data));
Needs '&' ?
memset(&data, 0, sizeof(data));
> server = kzalloc(sizeof(struct ncp_server), GFP_KERNEL);
> if (!server)
> return -ENOMEM;
> @@ -496,7 +496,6 @@ static int ncp_fill_super(struct super_b
> struct ncp_mount_data_v4* md = (struct ncp_mount_data_v4*)raw_data;
>
> data.flags = md->flags;
> - data.int_flags = 0;
> data.mounted_uid = md->mounted_uid;
> data.wdog_pid = find_get_pid(md->wdog_pid);
> data.ncp_fd = md->ncp_fd;
> @@ -507,7 +506,6 @@ static int ncp_fill_super(struct super_b
> data.file_mode = md->file_mode;
> data.dir_mode = md->dir_mode;
> data.info_fd = -1;
> - data.mounted_vol[0] = 0;
> }
> break;
> default:
> _
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
--
Tim Gardner tim.gardner@canonical.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH]initialize the array of fs/ncpfs/inode.c
2011-04-11 23:18 ` Andrew Morton
2011-04-11 23:28 ` Tim Gardner
@ 2011-04-12 3:17 ` Harry Wei
1 sibling, 0 replies; 4+ messages in thread
From: Harry Wei @ 2011-04-12 3:17 UTC (permalink / raw)
To: Andrew Morton
Cc: tim.gardner, linux-kernel, petr, viro, arnd, npiggin, jens.axboe,
greg, joe
On Mon, Apr 11, 2011 at 04:18:38PM -0700, Andrew Morton wrote:
> On Sun, 10 Apr 2011 18:08:18 +0800
> Harry Wei <jiaweiwei.xiyou@gmail.com> wrote:
>
> > fs/ncpfs/inode.c: In function 'ncp_fill_super':
> > fs/ncpfs/inode.c:451: warning: 'data.mounted_vol[1u]' may be used
>
> It's notabug, but we can easily fix it with a memset().
>
> Reported-by: Harry Wei <jiaweiwei.xiyou@gmail.com>
> Cc: Petr Vandrovec <petr@vandrovec.name>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> ---
>
> fs/ncpfs/inode.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> - data.wdog_pid = NULL;
> + memset(data, 0, sizeof(data));
Hi Morton,
It really need a '&' for data, i think. So i have corrected
your patch like following.
Thanks.
Harry Wei.
Reported-by: Harry Wei <jiaweiwei.xiyou@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Harry Wei <jiaweiwei.xiyou@gmail.com>
---
fs/ncpfs/inode.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff -puN fs/ncpfs/inode.c~fs-ncpfs-inodec-suppress-used-uninitialised-warning fs/ncpfs/inode.c
--- a/fs/ncpfs/inode.c~fs-ncpfs-inodec-suppress-used-uninitialised-warning
+++ a/fs/ncpfs/inode.c
@@ -461,7 +461,7 @@ static int ncp_fill_super(struct super_b
#endif
struct ncp_entry_info finfo;
- data.wdog_pid = NULL;
+ memset(&data, 0, sizeof(data));
server = kzalloc(sizeof(struct ncp_server), GFP_KERNEL);
if (!server)
return -ENOMEM;
@@ -496,7 +496,6 @@ static int ncp_fill_super(struct super_b
struct ncp_mount_data_v4* md = (struct ncp_mount_data_v4*)raw_data;
data.flags = md->flags;
- data.int_flags = 0;
data.mounted_uid = md->mounted_uid;
data.wdog_pid = find_get_pid(md->wdog_pid);
data.ncp_fd = md->ncp_fd;
@@ -507,7 +506,6 @@ static int ncp_fill_super(struct super_b
data.file_mode = md->file_mode;
data.dir_mode = md->dir_mode;
data.info_fd = -1;
- data.mounted_vol[0] = 0;
}
break;
default:
_
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-04-12 3:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-10 10:08 [PATCH]initialize the array of fs/ncpfs/inode.c Harry Wei
2011-04-11 23:18 ` Andrew Morton
2011-04-11 23:28 ` Tim Gardner
2011-04-12 3:17 ` Harry Wei
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox