All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dtor_core@ameritech.net>
To: linux-kernel@vger.kernel.org
Cc: Denis Vlasenko <vda@port.imtp.ilyichevsk.odessa.ua>
Subject: Re: [OOPS] linux-2.6.7-bk20: possible use-after-free in platform_device_unregister()
Date: Sat, 10 Jul 2004 14:49:29 -0500	[thread overview]
Message-ID: <200407101449.30408.dtor_core@ameritech.net> (raw)
In-Reply-To: <200407102131.10194.vda@port.imtp.ilyichevsk.odessa.ua>

On Saturday 10 July 2004 01:31 pm, Denis Vlasenko wrote:
> void platform_device_unregister(struct platform_device * pdev)
> {
> ? ? ? ? int i;
> 
> ? ? ? ? if (pdev) {
> ? ? ? ? ? ? ? ? device_unregister(&pdev->dev);
>

Here depca_platform_release kicks in and frees platform device structure.
platform_device_unregister should save pointer to resources. 
 
> ? ? ? ? ? ? ? ? for (i = 0; i < pdev->num_resources; i++) {
> ? ? ? ? ? ? ? ? ? ? ? ? struct resource *r = &pdev->resource[i];
> ===> ? ? ? ? ? ? ? ? ? ?if (r->flags & (IORESOURCE_MEM|IORESOURCE_IO))
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? release_resource(r);
> ? ? ? ? ? ? ? ? }
> ? ? ? ? }
> }
> 

Does the following help (hopefully it will apply - I have just a tad
different tree):

===== drivers/base/platform.c 1.21 vs edited =====
--- 1.21/drivers/base/platform.c	2004-07-04 19:56:37 -05:00
+++ edited/drivers/base/platform.c	2004-07-10 14:44:51 -05:00
@@ -143,13 +143,15 @@
  */
 void platform_device_unregister(struct platform_device * pdev)
 {
-	int i;
-
 	if (pdev) {
+		int i, num_resources = pdev->num_resources;
+		struct resource *r, *resources = pdev->resource;
+
+		/* this call may free pdev, that's why we saved resource data */
 		device_unregister(&pdev->dev);
 
-		for (i = 0; i < pdev->num_resources; i++) {
-			struct resource *r = &pdev->resource[i];
+		for (i = 0; i < num_resources; i++) {
+			r = &resources[i];
 			if (r->flags & (IORESOURCE_MEM|IORESOURCE_IO))
 				release_resource(r);
 		}

      reply	other threads:[~2004-07-10 19:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-10 18:31 [OOPS] linux-2.6.7-bk20: possible use-after-free in platform_device_unregister() Denis Vlasenko
2004-07-10 19:49 ` Dmitry Torokhov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200407101449.30408.dtor_core@ameritech.net \
    --to=dtor_core@ameritech.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vda@port.imtp.ilyichevsk.odessa.ua \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.