Skip to contentSkip to conversation

Initialize pointer on request_firmware

PATCH In review Lucas C. Villa Real 4 participants 9 messages Sep 22, 2011 – Sep 27, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Initialize pointer on request_firmware

Hello, folks,

I've seen some kernel oopses when suspending my machine. The problem comes from isight_firmware, which assumes that, on error, a call to request_firmware() will initialize the provided pointer to the firmware image to NULL.

The patch below fixes the isight_firmware side of the problem and also ensures that request_firmware() always sets the pointer to NULL on such cases (it currently does that for all except one situation).

drivers/base/firmware_class.c renamed from drivers/base/firmware_class.c.orig +1 -0
@@ -523,6 +523,7 @@ static int _request_firmware(const struc
 
 	if (WARN_ON(usermodehelper_is_disabled())) {
 		dev_err(device, "firmware: %s will not be loaded\n", name);
+		*firmware_p = NULL;
 		return -EBUSY;
 	}
 
drivers/usb/misc/isight_firmware.c renamed from drivers/usb/misc/isight_firmware.c.orig +1 -1
@@ -39,7 +39,7 @@ static int isight_firmware_load(struct u
 {
 	struct usb_device *dev = interface_to_usbdev(intf);
 	int llen, len, req, ret = 0;
-	const struct firmware *firmware;
+	const struct firmware *firmware = NULL;
 	unsigned char *buf = kmalloc(50, GFP_KERNEL);
 	unsigned char data[4];
 	const u8 *ptr;
#1 lore raw
Quoted 11 lines · Lucas C. Villa Real

Hello, folks,

I've seen some kernel oopses when suspending my machine. The problem comes from isight_firmware, which assumes that, on error, a call to request_firmware() will initialize the provided pointer to the firmware image to NULL.

The patch below fixes the isight_firmware side of the problem and also ensures that request_firmware() always sets the pointer to NULL on such cases (it currently does that for all except one situation).

drivers/base/firmware_class.c static int _request_firmware(const struc · line 528

Quoted 6 lines
drivers/base/firmware_class.c renamed from drivers/base/firmware_class.c.orig +1 -0
@@ -523,6 +523,7 @@ static int _request_firmware(const struc
 
 	if (WARN_ON(usermodehelper_is_disabled())) {
 		dev_err(device, "firmware: %s will not be loaded\n", name);
+		*firmware_p = NULL;
 		return -EBUSY;
 	}

Looks like f45f3c1f3f616 needs backporting to stable, if it hasn't happened yet. Oh, and then there's caca9510ff4e5 too which adds this exit path to the goto out label as the rest of the function.

Adding some more people to Cc.

Quoted 17 lines
drivers/usb/misc/isight_firmware.c renamed from drivers/usb/misc/isight_firmware.c.orig +1 -2
@@ -39,7 +39,7 @@ static int isight_firmware_load(struct u
 {
 	struct usb_device *dev = interface_to_usbdev(intf);
 	int llen, len, req, ret = 0;
-	const struct firmware *firmware;
+	const struct firmware *firmware = NULL;
 	unsigned char *buf = kmalloc(50, GFP_KERNEL);
 	unsigned char data[4];
 	const u8 *ptr;
--

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

Signature · 2 lines
Regards/Gruss,
    Boris.
#2 lore raw
Quoted 13 lines · Borislav Petkov
Quoted 12 lines · Lucas C. Villa Real

Hello, folks,

I've seen some kernel oopses when suspending my machine. The problem comes from isight_firmware, which assumes that, on error, a call to request_firmware() will initialize the provided pointer to the firmware image to NULL.

The patch below fixes the isight_firmware side of the problem and also ensures that request_firmware() always sets the pointer to NULL on such cases (it currently does that for all except one situation).

drivers/base/firmware_class.c renamed from drivers/base/firmware_class.c.orig +0 -0
@@ -523,6 +523,7 @@ static int _request_firmware(const struc
 
Quoted 8 lines

drivers/base/firmware_class.c static int _request_firmware(const struc · line 528

Quoted 5 lines
drivers/base/firmware_class.c renamed from drivers/base/firmware_class.c.orig +1 -0
 	if (WARN_ON(usermodehelper_is_disabled())) {
 		dev_err(device, "firmware: %s will not be loaded\n", name);
+		*firmware_p = NULL;
 		return -EBUSY;
 	}

Looks like f45f3c1f3f616 needs backporting to stable, if it hasn't happened yet.

What stable tree? That patch was in the 2.6.36 release, so 3.0-stable doesn't need it, right?

Quoted 2 lines

Oh, and then there's caca9510ff4e5 too which adds this exit path to the goto out label as the rest of the function.

But that was only due to other problems.

Again, I don't understand what the issue really is here.

confused,

greg k-h

#3 lore raw
Quoted 23 lines · Greg KH
Quoted 13 lines · Borislav Petkov
Quoted 12 lines · Lucas C. Villa Real

Hello, folks,

I've seen some kernel oopses when suspending my machine. The problem comes from isight_firmware, which assumes that, on error, a call to request_firmware() will initialize the provided pointer to the firmware image to NULL.

The patch below fixes the isight_firmware side of the problem and also ensures that request_firmware() always sets the pointer to NULL on such cases (it currently does that for all except one situation).

drivers/base/firmware_class.c renamed from drivers/base/firmware_class.c.orig +0 -0
@@ -523,6 +523,7 @@ static int _request_firmware(const struc
 
Quoted 8 lines

drivers/base/firmware_class.c static int _request_firmware(const struc · line 528

Quoted 5 lines
drivers/base/firmware_class.c renamed from drivers/base/firmware_class.c.orig +1 -0
 	if (WARN_ON(usermodehelper_is_disabled())) {
 		dev_err(device, "firmware: %s will not be loaded\n", name);
+		*firmware_p = NULL;
 		return -EBUSY;
 	}

Looks like f45f3c1f3f616 needs backporting to stable, if it hasn't happened yet.

Quoted 2 lines

What stable tree? That patch was in the 2.6.36 release, so 3.0-stable doesn't need it, right?

Judging by the diff lines above, 3.0.4 doesn't seem to have it. Wait, lemme check... uh no, I can't, the damn k.org thing is still down :-(.

Quoted 4 lines
Quoted 2 lines

Oh, and then there's caca9510ff4e5 too which adds this exit path to the goto out label as the rest of the function.

But that was only due to other problems.

That second one adds the goto thing to the "out:" label where the firmware_p gets NULLed. IOW, it prepares the code for f45f3c1f3f616.

Does that make more sense now?

Signature · 2 lines
Regards/Gruss,
Boris.
#4 lore raw
Quoted 24 lines · Borislav Petkov
Quoted 23 lines · Greg KH
Quoted 21 lines · Borislav Petkov
Quoted 11 lines · Lucas C. Villa Real

Hello, folks,

I've seen some kernel oopses when suspending my machine. The problem comes from isight_firmware, which assumes that, on error, a call to request_firmware() will initialize the provided pointer to the firmware image to NULL.

The patch below fixes the isight_firmware side of the problem and also ensures that request_firmware() always sets the pointer to NULL on such cases (it currently does that for all except one situation).

drivers/base/firmware_class.c static int _request_firmware(const struc · line 528

Quoted 6 lines
drivers/base/firmware_class.c renamed from drivers/base/firmware_class.c.orig +1 -0
@@ -523,6 +523,7 @@ static int _request_firmware(const struc
 
 	if (WARN_ON(usermodehelper_is_disabled())) {
 		dev_err(device, "firmware: %s will not be loaded\n", name);
+		*firmware_p = NULL;
 		return -EBUSY;
 	}

Looks like f45f3c1f3f616 needs backporting to stable, if it hasn't happened yet.

Quoted 5 lines
Quoted 2 lines

What stable tree? That patch was in the 2.6.36 release, so 3.0-stable doesn't need it, right?

Judging by the diff lines above, 3.0.4 doesn't seem to have it. Wait, lemme check... uh no, I can't, the damn k.org thing is still down :-(.

The patch was in the 2.6.36 kernel, so by nature of that, 3.0 will also have it, right?

Quoted 9 lines
Quoted 4 lines
Quoted 2 lines

Oh, and then there's caca9510ff4e5 too which adds this exit path to the goto out label as the rest of the function.

But that was only due to other problems.

That second one adds the goto thing to the "out:" label where the firmware_p gets NULLed. IOW, it prepares the code for f45f3c1f3f616.

Does that make more sense now?

Nope, sorry, still confused :)

How about, what patches are needed for the 3.0-stable kernel tree in order to resolve these issue? Git commit ids please.

thanks,

greg k-h

#5 lore raw
Quoted 2 lines · Greg KH

The patch was in the 2.6.36 kernel, so by nature of that, 3.0 will also have it, right?

Ok, a colleague of mine gave me 3.0.4 to stare at - and you're right the patch is there. So what is still missing is caca9510ff4e5 from upstream which reroutes the exit path so that firmware_p is NULLed before returning -EBUSY.

Lucas, can you apply caca9510ff4e5 from upstream and verify it fixes the issue for ya?

Thanks.

Signature · 2 lines
Regards/Gruss,
Boris.
#6 lore raw
Quoted 11 lines · Borislav Petkov
Quoted 2 lines · Greg KH

The patch was in the 2.6.36 kernel, so by nature of that, 3.0 will also have it, right?

Ok, a colleague of mine gave me 3.0.4 to stare at - and you're right the patch is there. So what is still missing is caca9510ff4e5 from upstream which reroutes the exit path so that firmware_p is NULLed before returning -EBUSY.

Lucas, can you apply caca9510ff4e5 from upstream and verify it fixes the issue for ya?

Sure. I'll do that tonight and will let you now -- the laptop I'm using right now doesn't suffer from that problem.

Thanks,

Signature · 3 lines
Lucas
"If you're looking for a reason I've a reason to give: pleasure,
little treasure"
#7 lore raw
Quoted 10 lines · Lucas C. Villa Real
Quoted 9 lines · Borislav Petkov
Quoted 2 lines · Greg KH

The patch was in the 2.6.36 kernel, so by nature of that, 3.0 will also have it, right?

Ok, a colleague of mine gave me 3.0.4 to stare at - and you're right the patch is there. So what is still missing is caca9510ff4e5 from upstream which reroutes the exit path so that firmware_p is NULLed before returning -EBUSY.

Quoted 5 lines
Quoted 2 lines

Lucas, can you apply caca9510ff4e5 from upstream and verify it fixes the issue for ya?

Sure. I'll do that tonight and will let you now -- the laptop I'm using right now doesn't suffer from that problem.

caca9510ff4e5 fixes it. Thanks for the pointer!

Best regards,

Signature · 3 lines
Lucas
"If you're looking for a reason I've a reason to give: pleasure,
little treasure"
#8 lore raw
Quoted 12 lines · Lucas C. Villa Real
Quoted 10 lines · Lucas C. Villa Real
Quoted 9 lines · Borislav Petkov
Quoted 2 lines · Greg KH

The patch was in the 2.6.36 kernel, so by nature of that, 3.0 will also have it, right?

Ok, a colleague of mine gave me 3.0.4 to stare at - and you're right the patch is there. So what is still missing is caca9510ff4e5 from upstream which reroutes the exit path so that firmware_p is NULLed before returning -EBUSY.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Lucas, can you apply caca9510ff4e5 from upstream and verify it fixes the issue for ya?

Sure. I'll do that tonight and will let you now -- the laptop I'm using right now doesn't suffer from that problem.

caca9510ff4e5 fixes it. Thanks for the pointer!

Looks like the ball is with Greg now :-).

Thanks.

Signature · 2 lines
Regards/Gruss,
    Boris.