1. 01 4月, 2020 1 次提交
  2. 26 3月, 2020 1 次提交
  3. 12 3月, 2020 1 次提交
    • C
      driver code: clarify and fix platform device DMA mask allocation · e3a36eb6
      Christoph Hellwig 提交于
      This does three inter-related things to clarify the usage of the
      platform device dma_mask field. In the process, fix the bug introduced
      by cdfee562 ("driver core: initialize a default DMA mask for
      platform device") that caused Artem Tashkinov's laptop to not boot with
      newer Fedora kernels.
      
      This does:
      
       - First off, rename the field to "platform_dma_mask" to make it
         greppable.
      
         We have way too many different random fields called "dma_mask" in
         various data structures, where some of them are actual masks, and
         some of them are just pointers to the mask. And the structures all
         have pointers to each other, or embed each other inside themselves,
         and "pdev" sometimes means "platform device" and sometimes it means
         "PCI device".
      
         So to make it clear in the code when you actually use this new field,
         give it a unique name (it really should be something even more unique
         like "platform_device_dma_mask", since it's per platform device, not
         per platform, but that gets old really fast, and this is unique
         enough in context).
      
         To further clarify when the field gets used, initialize it when we
         actually start using it with the default value.
      
       - Then, use this field instead of the random one-off allocation in
         platform_device_register_full() that is now unnecessary since we now
         already have a perfectly fine allocation for it in the platform
         device structure.
      
       - The above then allows us to fix the actual bug, where the error path
         of platform_device_register_full() would unconditionally free the
         platform device DMA allocation with 'kfree()'.
      
         That kfree() was dont regardless of whether the allocation had been
         done earlier with the (now removed) kmalloc, or whether
         setup_pdev_dma_masks() had already been used and the dma_mask pointer
         pointed to the mask that was part of the platform device.
      
      It seems most people never triggered the error path, or only triggered
      it from a call chain that set an explicit pdevinfo->dma_mask value (and
      thus caused the unnecessary allocation that was "cleaned up" in the
      error path) before calling platform_device_register_full().
      
      Robin Murphy points out that in Artem's case the wdat_wdt driver failed
      in platform_device_add(), and that was the one that had called
      platform_device_register_full() with pdevinfo.dma_mask = 0, and would
      have caused that kfree() of pdev.dma_mask corrupting the heap.
      
      A later unrelated kmalloc() then oopsed due to the heap corruption.
      
      Fixes: cdfee562 ("driver core: initialize a default DMA mask for platform device")
      Reported-bisected-and-tested-by: NArtem S. Tashkinov <aros@gmx.com>
      Reviewed-by: NRobin Murphy <robin.murphy@arm.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      e3a36eb6
  4. 22 1月, 2020 1 次提交
  5. 14 1月, 2020 1 次提交
  6. 10 12月, 2019 1 次提交
  7. 14 11月, 2019 2 次提交
  8. 06 11月, 2019 2 次提交
  9. 11 10月, 2019 1 次提交
  10. 07 10月, 2019 2 次提交
  11. 29 8月, 2019 2 次提交
  12. 23 8月, 2019 1 次提交
  13. 30 7月, 2019 3 次提交
  14. 15 7月, 2019 1 次提交
  15. 21 6月, 2019 1 次提交
  16. 30 4月, 2019 1 次提交
  17. 26 4月, 2019 3 次提交
  18. 02 3月, 2019 1 次提交
  19. 26 2月, 2019 1 次提交
    • M
      platform: set of_node in platform_device_register_full() · 2c1ea6ab
      Mans Rullgard 提交于
      If the provided fwnode is an OF node, set dev.of_node as well.
      
      Also add an of_node_reused flag to struct platform_device_info and copy
      this to the new device.  This is needed to avoid pinctrl settings being
      requested twice.  See 4e75e1d7 ("driver core: add helper to reuse a
      device-tree node") for a longer explanation.
      
      Some drivers are just shims that create extra "glue" devices with the
      DT device as parent and have the real driver bind to these.  In these
      cases, the glue device needs to get a reference to the original DT node
      in order for the main driver to access properties and child nodes.
      
      For example, the sunxi-musb driver creates such a glue device using
      platform_device_register_full().  Consequently, devices attached to
      this USB interface don't get associated with DT nodes, if present,
      the way they do with EHCI.
      
      This change will allow sunxi-musb and similar drivers to easily
      propagate the DT node to child devices as required.
      Signed-off-by: NMans Rullgard <mans@mansr.com>
      Reviewed-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2c1ea6ab
  20. 22 2月, 2019 1 次提交
  21. 21 2月, 2019 1 次提交
  22. 12 2月, 2019 1 次提交
  23. 05 1月, 2019 1 次提交
    • Q
      drivers/base/platform.c: kmemleak ignore a known leak · 967d3010
      Qian Cai 提交于
      unreferenced object 0xffff808ec6dc5a80 (size 128):
        comm "swapper/0", pid 1, jiffies 4294938063 (age 2560.530s)
        hex dump (first 32 bytes):
          ff ff ff ff 00 00 00 00 6b 6b 6b 6b 6b 6b 6b 6b  ........kkkkkkkk
          6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b  kkkkkkkkkkkkkkkk
        backtrace:
          [<00000000476dcf8c>] kmem_cache_alloc_trace+0x430/0x500
          [<000000004f708d37>] platform_device_register_full+0xbc/0x1e8
          [<000000006c2a7ec7>] acpi_create_platform_device+0x370/0x450
          [<00000000ef135642>] acpi_default_enumeration+0x34/0x78
          [<000000003bd9a052>] acpi_bus_attach+0x2dc/0x3e0
          [<000000003cf4f7f2>] acpi_bus_attach+0x108/0x3e0
          [<000000003cf4f7f2>] acpi_bus_attach+0x108/0x3e0
          [<000000002968643e>] acpi_bus_scan+0xb0/0x110
          [<0000000010dd0bd7>] acpi_scan_init+0x1a8/0x410
          [<00000000965b3c5a>] acpi_init+0x408/0x49c
          [<00000000ed4b9fe2>] do_one_initcall+0x178/0x7f4
          [<00000000a5ac5a74>] kernel_init_freeable+0x9d4/0xa9c
          [<0000000070ea6c15>] kernel_init+0x18/0x138
          [<00000000fb8fff06>] ret_from_fork+0x10/0x1c
          [<0000000041273a0d>] 0xffffffffffffffff
      
      Then, faddr2line pointed out this line,
      
      /*
       * This memory isn't freed when the device is put,
       * I don't have a nice idea for that though.  Conceptually
       * dma_mask in struct device should not be a pointer.
       * See http://thread.gmane.org/gmane.linux.kernel.pci/9081
       */
      pdev->dev.dma_mask =
      	kmalloc(sizeof(*pdev->dev.dma_mask), GFP_KERNEL);
      
      Since this leak has existed for more than 8 years and it does not
      reference other parts of the memory, let kmemleak ignore it, so users
      don't need to waste time reporting this in the future.
      
      Link: http://lkml.kernel.org/r/20181206160751.36211-1-cai@gmx.usSigned-off-by: NQian Cai <cai@gmx.us>
      Reviewed-by: NAndrew Morton <akpm@linux-foundation.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: "Rafael J . Wysocki" <rafael.j.wysocki@intel.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      967d3010
  24. 14 12月, 2018 2 次提交
  25. 06 12月, 2018 1 次提交
  26. 27 11月, 2018 1 次提交
  27. 31 10月, 2018 1 次提交
  28. 02 10月, 2018 1 次提交
  29. 01 10月, 2018 1 次提交
  30. 15 5月, 2018 1 次提交
  31. 03 5月, 2018 1 次提交