瀏覽代碼

Add explicit zeroing to "envp" array in device 'show' method

As Stephen Hemminger says, this is a "belt and suspenders" patch that
zeroes the envp array at allocation time, even though all the users
should NULL-terminate it anyway (and we've hopefully fixed everybody
that doesn't do that).

And we'll apparently clean the whole envp thing up for 2.6.24 anyway.

But let's just be robust, and do both this *and* make sure that all
users are doing the right thing.

Acked-by: Stephen Hemminger <shemminger@linux-foundation.org>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Linus Torvalds 17 年之前
父節點
當前提交
5309809129
共有 1 個文件被更改,包括 1 次插入0 次删除
  1. 1 0
      drivers/base/core.c

+ 1 - 0
drivers/base/core.c

@@ -284,6 +284,7 @@ static ssize_t show_uevent(struct device *dev, struct device_attribute *attr,
 
 
 	/* let the kset specific function add its keys */
 	/* let the kset specific function add its keys */
 	pos = data;
 	pos = data;
+	memset(envp, 0, sizeof(envp));
 	retval = kset->uevent_ops->uevent(kset, &dev->kobj,
 	retval = kset->uevent_ops->uevent(kset, &dev->kobj,
 					  envp, ARRAY_SIZE(envp),
 					  envp, ARRAY_SIZE(envp),
 					  pos, PAGE_SIZE);
 					  pos, PAGE_SIZE);