Skip to contentSkip to conversation

media: si470x-i2c: Move free() past last use of 'radio'

PATCH Applied Lee Jones 3 participants 8 messages Feb 3, 2020

Subsystems (3)
lore
Share & tools
lore

Lee Jones

author
#0 lore raw

PATCH 1/1 media: si470x-i2c: Move free() past last use of 'radio'

A pointer to 'struct si470x_device' is currently used after free:

drivers/media/radio/si470x/radio-si470x-i2c.c:462:25-30: ERROR: reference
preceded by free on line 460

Shift the call to free() down past its final use.

NB: Not sending to Mainline, since the problem does not exist there.

---
 drivers/media/radio/si470x/radio-si470x-i2c.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/radio/si470x/radio-si470x-i2c.c +1 -1
index ae7540b765e1d..aa12fd2663895 100644
@@ -483,10 +483,10 @@ static int si470x_i2c_remove(struct i2c_client *client)
 
 	free_irq(client->irq, radio);
 	video_unregister_device(&radio->videodev);
-	kfree(radio);
 
 	v4l2_ctrl_handler_free(&radio->hdl);
 	v4l2_device_unregister(&radio->v4l2_dev);
+	kfree(radio);
 	return 0;
 }
 
Signature · 1 line
2.24.0
#1 lore raw
Quoted 8 lines · Lee Jones

A pointer to 'struct si470x_device' is currently used after free:

drivers/media/radio/si470x/radio-si470x-i2c.c:462:25-30: ERROR: reference
preceded by free on line 460

Shift the call to free() down past its final use.

NB: Not sending to Mainline, since the problem does not exist there.

It doesn't exist there because of a bad merge? What commit caused the problem?

thanks,

greg k-h

#2 lore raw
Quoted 6 lines · Greg KH
Quoted 5 lines · Lee Jones

A pointer to 'struct si470x_device' is currently used after free:

drivers/media/radio/si470x/radio-si470x-i2c.c:462:25-30: ERROR: reference
preceded by free on line 460

Quoted 6 lines
Quoted 3 lines

Shift the call to free() down past its final use.

NB: Not sending to Mainline, since the problem does not exist there.

It doesn't exist there because of a bad merge? What commit caused the problem?

Ah, found it, it was 2df200ab234a ("media: si470x-i2c: add missed operations in remove")

author
#3 lore raw
Quoted 9 lines · Greg KH
Quoted 8 lines · Greg KH
Quoted 7 lines · Lee Jones

A pointer to 'struct si470x_device' is currently used after free:

drivers/media/radio/si470x/radio-si470x-i2c.c:462:25-30: ERROR: reference
preceded by free on line 460

Shift the call to free() down past its final use.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

NB: Not sending to Mainline, since the problem does not exist there.

It doesn't exist there because of a bad merge? What commit caused the problem?

Ah, found it, it was 2df200ab234a ("media: si470x-i2c: add missed operations in remove")

I was about to follow up with a v2:

"NB: Cauased during the backporting of upstream commit 2df200ab234a
("media: si470x-i2c: add missed operations in remove"). This issue does not exist in Mainline since the kfree() was removed in v5.0 as part of commit f86c51b66bf6 ("media: si470x-i2c: Use managed resource helpers")."

Signature · 4 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
maintainer Applied
#4 lore raw

Patch "media: si470x-i2c: Move free() past last use of 'radio'" has been added to the 4.4-stable tree

In reply to Lee Jones

This is a note to let you know that I've just added the patch titled

    media: si470x-i2c: Move free() past last use of 'radio'

to the 4.4-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:

     media-si470x-i2c-move-free-past-last-use-of-radio.patch

and it can be found in the queue-4.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

From [email protected] Mon Feb 3 14:58:36 2020
From: Lee Jones <[email protected]>
Date: Mon, 3 Feb 2020 13:21:30 +0000
Subject: media: si470x-i2c: Move free() past last use of 'radio'
To: [email protected]
Cc: [email protected], [email protected]
Message-ID: <[email protected]>

From: Lee Jones <[email protected]>

A pointer to 'struct si470x_device' is currently used after free:

drivers/media/radio/si470x/radio-si470x-i2c.c:462:25-30: ERROR: reference
preceded by free on line 460

Shift the call to free() down past its final use.

NB: Not sending to Mainline, since the problem does not exist there, it was caused by the backport of 2df200ab234a ("media: si470x-i2c: add missed operations in remove") to the stable trees.

---
 drivers/media/radio/si470x/radio-si470x-i2c.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/radio/si470x/radio-si470x-i2c.c +1 -1
@@ -458,10 +458,10 @@ static int si470x_i2c_remove(struct i2c_
 
 	free_irq(client->irq, radio);
 	video_unregister_device(&radio->videodev);
-	kfree(radio);
 
 	v4l2_ctrl_handler_free(&radio->hdl);
 	v4l2_device_unregister(&radio->v4l2_dev);
+	kfree(radio);
 	return 0;
 }
 

Patches currently in stable-queue which might be from [email protected] are

queue-4.4/media-si470x-i2c-move-free-past-last-use-of-radio.patch

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

maintainer Applied
#5 lore raw

Patch "media: si470x-i2c: Move free() past last use of 'radio'" has been added to the 4.9-stable tree

In reply to Lee Jones

This is a note to let you know that I've just added the patch titled

    media: si470x-i2c: Move free() past last use of 'radio'

to the 4.9-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:

     media-si470x-i2c-move-free-past-last-use-of-radio.patch

and it can be found in the queue-4.9 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

From [email protected] Mon Feb 3 14:58:36 2020
From: Lee Jones <[email protected]>
Date: Mon, 3 Feb 2020 13:21:30 +0000
Subject: media: si470x-i2c: Move free() past last use of 'radio'
To: [email protected]
Cc: [email protected], [email protected]
Message-ID: <[email protected]>

From: Lee Jones <[email protected]>

A pointer to 'struct si470x_device' is currently used after free:

drivers/media/radio/si470x/radio-si470x-i2c.c:462:25-30: ERROR: reference
preceded by free on line 460

Shift the call to free() down past its final use.

NB: Not sending to Mainline, since the problem does not exist there, it was caused by the backport of 2df200ab234a ("media: si470x-i2c: add missed operations in remove") to the stable trees.

---
 drivers/media/radio/si470x/radio-si470x-i2c.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/radio/si470x/radio-si470x-i2c.c +1 -1
@@ -458,10 +458,10 @@ static int si470x_i2c_remove(struct i2c_
 
 	free_irq(client->irq, radio);
 	video_unregister_device(&radio->videodev);
-	kfree(radio);
 
 	v4l2_ctrl_handler_free(&radio->hdl);
 	v4l2_device_unregister(&radio->v4l2_dev);
+	kfree(radio);
 	return 0;
 }
 

Patches currently in stable-queue which might be from [email protected] are

queue-4.9/media-si470x-i2c-move-free-past-last-use-of-radio.patch

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

maintainer Applied
#6 lore raw

Patch "media: si470x-i2c: Move free() past last use of 'radio'" has been added to the 4.14-stable tree

In reply to Lee Jones

This is a note to let you know that I've just added the patch titled

    media: si470x-i2c: Move free() past last use of 'radio'

to the 4.14-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:

     media-si470x-i2c-move-free-past-last-use-of-radio.patch

and it can be found in the queue-4.14 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

From [email protected] Mon Feb 3 14:58:36 2020
From: Lee Jones <[email protected]>
Date: Mon, 3 Feb 2020 13:21:30 +0000
Subject: media: si470x-i2c: Move free() past last use of 'radio'
To: [email protected]
Cc: [email protected], [email protected]
Message-ID: <[email protected]>

From: Lee Jones <[email protected]>

A pointer to 'struct si470x_device' is currently used after free:

drivers/media/radio/si470x/radio-si470x-i2c.c:462:25-30: ERROR: reference
preceded by free on line 460

Shift the call to free() down past its final use.

NB: Not sending to Mainline, since the problem does not exist there, it was caused by the backport of 2df200ab234a ("media: si470x-i2c: add missed operations in remove") to the stable trees.

---
 drivers/media/radio/si470x/radio-si470x-i2c.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/radio/si470x/radio-si470x-i2c.c +1 -1
@@ -453,10 +453,10 @@ static int si470x_i2c_remove(struct i2c_
 
 	free_irq(client->irq, radio);
 	video_unregister_device(&radio->videodev);
-	kfree(radio);
 
 	v4l2_ctrl_handler_free(&radio->hdl);
 	v4l2_device_unregister(&radio->v4l2_dev);
+	kfree(radio);
 	return 0;
 }
 

Patches currently in stable-queue which might be from [email protected] are

queue-4.14/media-si470x-i2c-move-free-past-last-use-of-radio.patch

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

maintainer Applied
#7 lore raw

Patch "media: si470x-i2c: Move free() past last use of 'radio'" has been added to the 4.19-stable tree

In reply to Lee Jones

This is a note to let you know that I've just added the patch titled

    media: si470x-i2c: Move free() past last use of 'radio'

to the 4.19-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:

     media-si470x-i2c-move-free-past-last-use-of-radio.patch

and it can be found in the queue-4.19 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

From [email protected] Mon Feb 3 14:58:36 2020
From: Lee Jones <[email protected]>
Date: Mon, 3 Feb 2020 13:21:30 +0000
Subject: media: si470x-i2c: Move free() past last use of 'radio'
To: [email protected]
Cc: [email protected], [email protected]
Message-ID: <[email protected]>

From: Lee Jones <[email protected]>

A pointer to 'struct si470x_device' is currently used after free:

drivers/media/radio/si470x/radio-si470x-i2c.c:462:25-30: ERROR: reference
preceded by free on line 460

Shift the call to free() down past its final use.

NB: Not sending to Mainline, since the problem does not exist there, it was caused by the backport of 2df200ab234a ("media: si470x-i2c: add missed operations in remove") to the stable trees.

---
 drivers/media/radio/si470x/radio-si470x-i2c.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/radio/si470x/radio-si470x-i2c.c +1 -1
@@ -483,10 +483,10 @@ static int si470x_i2c_remove(struct i2c_
 
 	free_irq(client->irq, radio);
 	video_unregister_device(&radio->videodev);
-	kfree(radio);
 
 	v4l2_ctrl_handler_free(&radio->hdl);
 	v4l2_device_unregister(&radio->v4l2_dev);
+	kfree(radio);
 	return 0;
 }
 

Patches currently in stable-queue which might be from [email protected] are

queue-4.19/media-si470x-i2c-move-free-past-last-use-of-radio.patch

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel