1. 25 8月, 2017 2 次提交
    • B
      of/device: Fix of_device_get_modalias() buffer handling · 8c2a75e5
      Bjorn Andersson 提交于
      of_device_request_module() calls of_device_get_modalias() with "len" 0,
      to calculate the size of the buffer needed to store the result, but due
      to integer promotion the ssize_t "len" will be compared as unsigned with
      strlen(compat) and the loop will generally never break. This results in
      a call to snprintf() with a negative len, which triggers below warning,
      followed by a dereference of a invalid pointer:
      
        [    3.060067] WARNING: CPU: 0 PID: 51 at lib/vsprintf.c:2122 vsnprintf+0x348/0x6d8
        ...
        [    3.060301] [<ffffff800891ede8>] vsnprintf+0x348/0x6d8
        [    3.060308] [<ffffff800891f248>] snprintf+0x48/0x50
        [    3.060316] [<ffffff80086a7c80>] of_device_get_modalias+0x108/0x160
        [    3.060322] [<ffffff80086a7cf8>] of_device_request_module+0x20/0x88
        ...
      
      Further more of_device_get_modalias() is supposed to return the number
      of bytes needed to store the entire modalias, so the loop needs to
      continue accumulate the total size even though the buffer is full.
      
      Finally the function is not expected to ensure space for the NUL, nor
      include it in the returned size, so only 1 should be added to the length
      of "compat" in the loop (to account for the character 'C').
      
      Fixes: bc575064 ("of/device: use of_property_for_each_string to parse compatible strings")
      Cc: Rob Herring <robh@kernel.org>
      Signed-off-by: NBjorn Andersson <bjorn.andersson@linaro.org>
      Signed-off-by: NRob Herring <robh@kernel.org>
      8c2a75e5
    • B
      of/device: Prevent buffer overflow in of_device_modalias() · 08ab58d9
      Bjorn Andersson 提交于
      As of_device_get_modalias() returns the number of bytes that would have
      been written to the target string, regardless of how much did fit in the
      buffer, it's possible that the returned index points beyond the buffer
      passed to of_device_modalias() - causing memory beyond the buffer to be
      null terminated.
      
      Fixes: 0634c295 ("of: Add function for generating a DT modalias with a newline")
      Cc: Rob Herring <robh@kernel.org>
      Cc: stable@vger.kernel.org
      Signed-off-by: NBjorn Andersson <bjorn.andersson@linaro.org>
      Signed-off-by: NRob Herring <robh@kernel.org>
      08ab58d9
  2. 02 8月, 2017 1 次提交
  3. 19 7月, 2017 1 次提交
  4. 30 5月, 2017 1 次提交
    • S
      iommu/of: Ignore all errors except EPROBE_DEFER · a37b19a3
      Sricharan R 提交于
      While deferring the probe of IOMMU masters, xlate and
      add_device callbacks called from of_iommu_configure
      can pass back error values like -ENODEV, which means
      the IOMMU cannot be connected with that master for real
      reasons. Before the IOMMU probe deferral, all such errors
      were ignored. Now all those errors are propagated back,
      killing the master's probe for such errors. Instead ignore
      all the errors except EPROBE_DEFER, which is the only one
      of concern and let the master work without IOMMU, thus
      restoring the old behavior. Also make explicit that
      of_dma_configure handles only -EPROBE_DEFER from
      of_iommu_configure.
      
      Fixes: 7b07cbef ("iommu: of: Handle IOMMU lookup failure with deferred probing or error")
      Reported-by: NGeert Uytterhoeven <geert@linux-m68k.org>
      Tested-by: NMagnus Damn <magnus.damn@gmail.com>
      Signed-off-by: NSricharan R <sricharan@codeaurora.org>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      a37b19a3
  5. 20 4月, 2017 3 次提交
  6. 23 3月, 2017 1 次提交
    • R
      of: Add function for generating a DT modalias with a newline · 0634c295
      Rob Herring 提交于
      The modalias sysfs attr is lacking a newline for DT aliases on platform
      devices. The macio and ibmebus correctly add the newline, but open code it.
      Introduce a new function, of_device_modalias(), that fills the buffer with
      the modalias including the newline and update users of the old
      of_device_get_modalias function.
      Signed-off-by: NRob Herring <robh@kernel.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Frank Rowand <frowand.list@gmail.com>
      Cc: linuxppc-dev@lists.ozlabs.org
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0634c295
  7. 22 3月, 2017 1 次提交
    • R
      of: fix of_device_get_modalias returned length when truncating buffers · bcf54d53
      Rob Herring 提交于
      If the length of the modalias is greater than the buffer size, then the
      modalias is truncated. However the untruncated length is returned which
      will cause an error. Fix this to return the truncated length. If an error
      in the case was desired, then then we should just return -ENOMEM.
      
      The reality is no device will ever have 4KB of compatible strings to hit
      this case.
      Signed-off-by: NRob Herring <robh@kernel.org>
      Cc: Frank Rowand <frowand.list@gmail.com>
      bcf54d53
  8. 20 1月, 2017 2 次提交
  9. 09 5月, 2016 1 次提交
  10. 18 10月, 2015 1 次提交
  11. 18 9月, 2015 1 次提交
  12. 29 5月, 2015 1 次提交
  13. 13 3月, 2015 1 次提交
  14. 04 3月, 2015 2 次提交
  15. 07 7月, 2014 1 次提交
  16. 17 1月, 2014 1 次提交
  17. 06 2月, 2013 1 次提交
    • S
      of: Output devicetree alias names in uevent · ced4eec9
      Stepan Moskovchenko 提交于
      In some situations, userspace may want to resolve a
      device by function and logical number (ie, "serial0")
      rather than by the base address or full device path. Being
      able to resolve a device by alias frees userspace from the
      burden of otherwise having to maintain a mapping between
      device addresses and their logical assignments on each
      platform when multiple instances of the same hardware block
      are present in the system.
      
      Although the uevent device attribute contains devicetree
      compatible information and the full device path, the uevent
      does not list the alises that may have been defined for the
      device.
      Signed-off-by: NStepan Moskovchenko <stepanm@codeaurora.org>
      [grant.likely: Removed OF_ALIAS_N field; I don't think it's needed]
      [grant.likely: Added #ifndef _LINUX_OF_PRIVATE_H wrapper]
      Signed-off-by: NGrant Likely <grant.likely@secretlab.ca>
      ced4eec9
  18. 02 2月, 2012 1 次提交
    • G
      drivercore: Output common devicetree information in uevent · 07d57a32
      Grant Likely 提交于
      When userspace needs to find a specific device, it currently isn't easy to
      resolve a /sys/devices/ path from a specific device tree node.  Nor is it
      easy to obtain the compatible list for devices.
      
      This patch generalizes the code that inserts OF_* values into the uevent
      device attribute so that any device that is attached to an OF node will
      have that information exported to userspace.  Without this patch only
      platform devices and some powerpc-specific busses have access to this
      data.
      
      The original function also creates a MODALIAS property for the compatible
      list, but that code has not been generalized into the common case because
      it has the potential to break module loading on a lot of bus types.  Bus
      types are still responsible for their own MODALIAS properties.
      
      Boot tested on ARM and compile tested on PowerPC and SPARC.
      Signed-off-by: NGrant Likely <grant.likely@secretlab.ca>
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Tobias Klauser <tklauser@distanz.ch>
      Cc: Frederic Lambert <frdrc66@gmail.com>
      Cc: Rob Herring <rob.herring@calxeda.com>
      Cc: Mark Brown <broonie@sirena.org.uk>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      07d57a32
  19. 28 2月, 2011 1 次提交
    • G
      dt/powerpc: move of_bus_type infrastructure to ibmebus · 710ac54b
      Grant Likely 提交于
      arch/powerpc/kernel/ibmebus.c is the only remaining user of the
      of_bus_type support code for initializing the bus and registering
      drivers.  All others have either been switched to the vanilla platform
      bus or already have their own infrastructure.
      
      This patch moves the functionality that ibmebus is using out of
      drivers/of/{platform,device}.c and into ibmebus.c where it is actually
      used.  Also renames the moved symbols from of_platform_* to
      ibmebus_bus_* to reflect the actual usage.
      
      This patch is part of moving all of the of_platform_bus_type users
      over to the platform_bus_type.
      Signed-off-by: NGrant Likely <grant.likely@secretlab.ca>
      710ac54b
  20. 22 10月, 2010 1 次提交
    • G
      of/device: Rework to use common platform_device_alloc() for allocating devices · 7096d042
      Grant Likely 提交于
      The current code allocates and manages platform_devices created from
      the device tree manually.  It also uses an unsafe shortcut for
      allocating the platform_device and the resource table at the same
      time. (which I added in the last rework; sorry).
      
      This patch refactors the code to use platform_device_alloc() for
      allocating new devices.  This reduces the amount of custom code
      implemented by of_platform, eliminates the unsafe alloc trick, and has
      the side benefit of letting the platform_bus code manage freeing the
      device data and resources when the device is freed.
      Signed-off-by: NGrant Likely <grant.likely@secretlab.ca>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Greg Kroah-Hartman <gregkh@suse.de>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Michal Simek <monstr@monstr.eu>
      7096d042
  21. 06 8月, 2010 1 次提交
  22. 24 7月, 2010 2 次提交
  23. 06 7月, 2010 3 次提交
    • G
      of/device: Add OF style matching helper function · 8cec0e7b
      Grant Likely 提交于
      Add of_driver_match_device() helper function.  This function can be used
      by bus types to determine if a driver works with a device when using OF
      style matching.  If CONFIG_OF is unselected, then it is a nop.
      Signed-off-by: NGrant Likely <grant.likely@secretlab.ca>
      CC: Greg Kroah-Hartman <gregkh@suse.de>
      CC: Michal Simek <monstr@monstr.eu>
      CC: Grant Likely <grant.likely@secretlab.ca>
      CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      CC: Stephen Rothwell <sfr@canb.auug.org.au>
      CC: linux-kernel@vger.kernel.org
      CC: microblaze-uclinux@itee.uq.edu.au
      CC: linuxppc-dev@ozlabs.org
      CC: devicetree-discuss@lists.ozlabs.org
      8cec0e7b
    • G
      of: Modify of_device_get_modalias to be passed struct device · 34a1c1e8
      Grant Likely 提交于
      Now that the of_node pointer is part of struct device,
      of_device_get_modalias could be used on any struct device
      that has the device node pointer set.  This patch changes
      of_device_get_modalias to accept a struct device instead
      of a struct of_device.
      Signed-off-by: NGrant Likely <grant.likely@secretlab.ca>
      CC: Michal Simek <monstr@monstr.eu>
      CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      CC: Wolfram Sang <w.sang@pengutronix.de>
      CC: Stephen Rothwell <sfr@canb.auug.org.au>
      CC: microblaze-uclinux@itee.uq.edu.au
      CC: linuxppc-dev@ozlabs.org
      34a1c1e8
    • G
      of/device: merge of_device_uevent · dd27dcda
      Grant Likely 提交于
      Merge common code between powerpc and microblaze
      Signed-off-by: NGrant Likely <grant.likely@secretlab.ca>
      CC: Michal Simek <monstr@monstr.eu>
      CC: Wolfram Sang <w.sang@pengutronix.de>
      CC: Stephen Rothwell <sfr@canb.auug.org.au>
      CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      CC: microblaze-uclinux@itee.uq.edu.au
      CC: linuxppc-dev@ozlabs.org
      dd27dcda
  24. 22 5月, 2010 1 次提交
  25. 19 5月, 2010 1 次提交
  26. 31 10月, 2008 1 次提交
    • J
      OF-device: Don't overwrite numa_node in device registration · 6098e2ee
      Jeremy Kerr 提交于
      Currently, the numa_node of OF-devices will be overwritten during
      device_register, which simply sets the node to -1.  On cell machines,
      this means that devices can't find their IOMMU, which is referenced
      through the device's numa node.
      
      Set the numa node for OF devices with no parent, and use the
      lower-level device_initialize and device_add functions, so that the
      node is preserved.
      
      We can remove the call to set_dev_node in of_device_alloc, as it
      will be overwritten during register.
      Signed-off-by: NJeremy Kerr <jk@ozlabs.org>
      Signed-off-by: NPaul Mackerras <paulus@samba.org>
      6098e2ee
  27. 20 8月, 2008 1 次提交
  28. 16 5月, 2008 1 次提交
  29. 14 5月, 2008 1 次提交
  30. 17 1月, 2008 1 次提交
  31. 20 7月, 2007 2 次提交