Re: [PATCH] musb: Fix bad call to kfree() in musb_free

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello.

On 04-08-2012 17:34, Brian Downing wrote:

Commit 622859634a663c5e55d0e2a2cdbb55ac058d97b3 removed a bunch of

   Please also specify the summary of that commit in parens.

#ifdefs from the musb code, including this change:

     @@ -1901,11 +1844,7 @@ static void musb_free(struct musb *musb)
                     dma_controller_destroy(c);
             }

     -#ifdef CONFIG_USB_MUSB_HDRC_HCD
     -       usb_put_hcd(musb_to_hcd(musb));
     -#else
             kfree(musb);
     -#endif
      }

      /*

Since musb comes from struct usb_hcd's hcd_priv, which is allocated on
the end of that struct, kfree'ing it is not going to work.  Replace
kfree(musb) with usb_put_hcd(musb_to_hcd(musb)), which appears to be
the right thing to do here.

Signed-off-by: Brian Downing <bdowning@xxxxxxxxx>
---
     Note that this patch is not sufficient to make musb device removal
     work, though it helps.  The way that resources are passed between
     the glue and core drivers does not seem to be okay; since they
     both acquire the same resources, when they get inserted into
     the resource tree what actually winds up happening is that the
     musb core's resources become the parent of the glue driver's.
     When platform_device_del'ing the musb core (which happens first) it
     winds up orphaning the glue driver's resources.  With kernel memory
     debugging on, you can see the glue driver's resource releasing hit
     upon a 0x6b6b6b6b pointer.

     I have not figured out a way to fix this resource problem that
     wouldn't be incredibly intrusive (modifying all glue drivers and all
     devices that create musb devices), but I managed to locally kludge
     around it for my purposes in the glue driver by explicitly releasing
     pdev->resource[0] before platform_device_add'ing the musb core,
     then re-inserting it after deleting the core.  Nasty!

MUSB core's resources should be subresources of the glue layer with limited range as they're usually only a subset of the full register range of the device. I have long had in mind doing the patches implementing the subresource logic but for the lack of time still haven't gotten around to it still.

WBR, Sergei

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


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux