Re: [PATCH] USB and Driver Core patches for 2.6.10

From: Greg KH
Date: Sat Jan 08 2005 - 05:43:32 EST


ChangeSet 1.1938.439.47, 2005/01/06 16:39:32-08:00, jbarnes@xxxxxxxxxxxx

[PATCH] fix oops when reading resourceN files in sysfs

On Thursday, January 6, 2005 12:25 pm, Jesse Barnes wrote:
> [Sorry about the bogus reply, I don't have the original message.]
>
> That shouldn't happen. Maybe you were running an old version of the tree
> or an old version of my sysfs mmap patch? When I do a 'bk pull' of
> gregkh's latest usb tree into a recent Linus tree, I get an -EINVAL, not an
> oops. An earlier version of my patch had this bug though, so maybe that's
> what you're seeing?

Ugg. How about this?

Zero out newly allocated bin_attributes for legacy I/O, memory and resource
files since we won't fill in all of the file operation methods. This will
allow the checks in bin.c for the existence of a method to work properly
instead of checking garbage memory.

Signed-off-by: Jesse Barnes <jbarnes@xxxxxxx>
Signed-off-by: Greg Kroah-Hartman <greg@xxxxxxxxx>


drivers/pci/pci-sysfs.c | 1 +
drivers/pci/probe.c | 1 +
2 files changed, 2 insertions(+)


diff -Nru a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
--- a/drivers/pci/pci-sysfs.c 2005-01-07 15:38:33 -08:00
+++ b/drivers/pci/pci-sysfs.c 2005-01-07 15:38:33 -08:00
@@ -295,6 +295,7 @@

res_attr = kmalloc(sizeof(*res_attr) + 10, GFP_ATOMIC);
if (res_attr) {
+ memset(res_attr, 0, sizeof(*res_attr) + 10);
pdev->res_attr[i] = res_attr;
/* Allocated above after the res_attr struct */
res_attr->attr.name = (char *)(res_attr + 1);
diff -Nru a/drivers/pci/probe.c b/drivers/pci/probe.c
--- a/drivers/pci/probe.c 2005-01-07 15:38:33 -08:00
+++ b/drivers/pci/probe.c 2005-01-07 15:38:33 -08:00
@@ -41,6 +41,7 @@
b->legacy_io = kmalloc(sizeof(struct bin_attribute) * 2,
GFP_ATOMIC);
if (b->legacy_io) {
+ memset(b->legacy_io, 0, sizeof(struct bin_attribute) * 2);
b->legacy_io->attr.name = "legacy_io";
b->legacy_io->size = 0xffff;
b->legacy_io->attr.mode = S_IRUSR | S_IWUSR;

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/