An error occurred fetching the project authors.
  1. 15 Jul, 2021 1 commit
  2. 11 Jun, 2021 2 commits
  3. 26 May, 2021 2 commits
    • Dan Carpenter's avatar
      mtd: core: Potential NULL dereference in mtd_otp_size() · c3c8c051
      Dan Carpenter authored
      If kmalloc() fails then it could lead to a NULL dereference.  Check and
      return -ENOMEM on error.
      
      Fixes: 4b361cfa ("mtd: core: add OTP nvmem provider support")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Reviewed-by: default avatarMichael Walle <michael@walle.cc>
      Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      Link: https://lore.kernel.org/linux-mtd/YJ6Iw3iNvGycAWV6@mwanda
      c3c8c051
    • Jon Hunter's avatar
      mtd: core: Fix freeing of otp_info buffer · bc8e157f
      Jon Hunter authored
      Commit 4b361cfa ("mtd: core: add OTP nvmem provider support") is
      causing the following panic ...
      
       ------------[ cut here ]------------
       kernel BUG at /local/workdir/tegra/linux_next/kernel/mm/slab.c:2730!
       Internal error: Oops - BUG: 0 [#1] PREEMPT SMP ARM
       Modules linked in:
       CPU: 3 PID: 1 Comm: swapper/0 Not tainted 5.13.0-rc2-next-20210518 #1
       Hardware name: NVIDIA Tegra SoC (Flattened Device Tree)
       PC is at ___cache_free+0x3f8/0x51c
       ...
       [<c029bb1c>] (___cache_free) from [<c029c658>] (kfree+0xac/0x1bc)
       [<c029c658>] (kfree) from [<c06da094>] (mtd_otp_size+0xc4/0x108)
       [<c06da094>] (mtd_otp_size) from [<c06dc864>] (mtd_device_parse_register+0xe4/0x2b4)
       [<c06dc864>] (mtd_device_parse_register) from [<c06e3ccc>] (spi_nor_probe+0x210/0x2c0)
       [<c06e3ccc>] (spi_nor_probe) from [<c06e9578>] (spi_probe+0x88/0xac)
       [<c06e9578>] (spi_probe) from [<c066891c>] (really_probe+0x214/0x3a4)
       [<c066891c>] (really_probe) from [<c0668b14>] (driver_probe_device+0x68/0xc0)
       [<c0668b14>] (driver_probe_device) from [<c0666cf8>] (bus_for_each_drv+0x5c/0xbc)
       [<c0666cf8>] (bus_for_each_drv) from [<c0668694>] (__device_attach+0xe4/0x150)
       [<c0668694>] (__device_attach) from [<c06679e0>] (bus_probe_device+0x84/0x8c)
       [<c06679e0>] (bus_probe_device) from [<c06657f8>] (device_add+0x48c/0x868)
       [<c06657f8>] (device_add) from [<c06eb784>] (spi_add_device+0xa0/0x168)
       [<c06eb784>] (spi_add_device) from [<c06ec9a8>] (spi_register_controller+0x8b8/0xb38)
       [<c06ec9a8>] (spi_register_controller) from [<c06ecc3c>] (devm_spi_register_controller+0x14/0x50)
       [<c06ecc3c>] (devm_spi_register_controller) from [<c06f0510>] (tegra_spi_probe+0x33c/0x450)
       [<c06f0510>] (tegra_spi_probe) from [<c066abec>] (platform_probe+0x5c/0xb8)
       [<c066abec>] (platform_probe) from [<c066891c>] (really_probe+0x214/0x3a4)
       [<c066891c>] (really_probe) from [<c0668b14>] (driver_probe_device+0x68/0xc0)
       [<c0668b14>] (driver_probe_device) from [<c0668e30>] (device_driver_attach+0x58/0x60)
       [<c0668e30>] (device_driver_attach) from [<c0668eb8>] (__driver_attach+0x80/0xc8)
       [<c0668eb8>] (__driver_attach) from [<c0666c48>] (bus_for_each_dev+0x78/0xb8)
       [<c0666c48>] (bus_for_each_dev) from [<c0667c44>] (bus_add_driver+0x164/0x1e8)
       [<c0667c44>] (bus_add_driver) from [<c066997c>] (driver_register+0x7c/0x114)
       [<c066997c>] (driver_register) from [<c010223c>] (do_one_initcall+0x50/0x2b0)
       [<c010223c>] (do_one_initcall) from [<c11011f0>] (kernel_init_freeable+0x1a8/0x1fc)
       [<c11011f0>] (kernel_init_freeable) from [<c0c09190>] (kernel_init+0x8/0x118)
       [<c0c09190>] (kernel_init) from [<c01001b0>] (ret_from_fork+0x14/0x24)
       ...
       ---[ end trace 0f652dd222de75d7 ]---
      
      In the function mtd_otp_size() a buffer is allocated by calling
      kmalloc() and a pointer to the buffer is stored in a variable 'info'.
      The pointer 'info' may then be incremented depending on the length
      returned from mtd_get_user/fact_prot_info(). If 'info' is incremented,
      when kfree() is called to free the buffer the above panic occurs because
      we are no longer passing the original address of the buffer allocated.
      Fix this by indexing through the buffer allocated to avoid incrementing
      the pointer.
      
      Fixes: 4b361cfa ("mtd: core: add OTP nvmem provider support")
      Signed-off-by: default avatarJon Hunter <jonathanh@nvidia.com>
      Reviewed-by: default avatarMichael Walle <michael@walle.cc>
      Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      Link: https://lore.kernel.org/linux-mtd/20210518185503.162787-1-jonathanh@nvidia.com
      bc8e157f
  4. 10 May, 2021 3 commits
  5. 16 Apr, 2021 1 commit
  6. 28 Mar, 2021 2 commits
  7. 11 Mar, 2021 3 commits
  8. 07 Dec, 2020 1 commit
  9. 20 Nov, 2020 1 commit
  10. 24 Sep, 2020 1 commit
  11. 27 Aug, 2020 1 commit
  12. 15 Jun, 2020 1 commit
  13. 31 May, 2020 1 commit
  14. 18 May, 2020 1 commit
    • Ricardo Ribalda Delgado's avatar
      mtd: Fix mtd not registered due to nvmem name collision · 7b01b723
      Ricardo Ribalda Delgado authored
      When the nvmem framework is enabled, a nvmem device is created per mtd
      device/partition.
      
      It is not uncommon that a device can have multiple mtd devices with
      partitions that have the same name. Eg, when there DT overlay is allowed
      and the same device with mtd is attached twice.
      
      Under that circumstances, the mtd fails to register due to a name
      duplication on the nvmem framework.
      
      With this patch we use the mtdX name instead of the partition name,
      which is unique.
      
      [    8.948991] sysfs: cannot create duplicate filename '/bus/nvmem/devices/Production Data'
      [    8.948992] CPU: 7 PID: 246 Comm: systemd-udevd Not tainted 5.5.0-qtec-standard #13
      [    8.948993] Hardware name: AMD Dibbler/Dibbler, BIOS 05.22.04.0019 10/26/2019
      [    8.948994] Call Trace:
      [    8.948996]  dump_stack+0x50/0x70
      [    8.948998]  sysfs_warn_dup.cold+0x17/0x2d
      [    8.949000]  sysfs_do_create_link_sd.isra.0+0xc2/0xd0
      [    8.949002]  bus_add_device+0x74/0x140
      [    8.949004]  device_add+0x34b/0x850
      [    8.949006]  nvmem_register.part.0+0x1bf/0x640
      ...
      [    8.948926] mtd mtd8: Failed to register NVMEM device
      
      Fixes: c4dfa25a ("mtd: add support for reading MTD devices via the nvmem API")
      Signed-off-by: default avatarRicardo Ribalda Delgado <ribalda@kernel.org>
      Acked-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
      7b01b723
  15. 11 May, 2020 1 commit
  16. 09 May, 2020 2 commits
  17. 11 Mar, 2020 1 commit
    • Miquel Raynal's avatar
      mtd: implement proper partition handling · 46b5889c
      Miquel Raynal authored
      Instead of collecting partitions in a flat list, create a hierarchy
      within the mtd_info structure: use a partitions list to keep track of
      the partitions of an MTD device (which might be itself a partition of
      another MTD device), a pointer to the parent device (NULL when the MTD
      device is the root one, not a partition).
      
      By also saving directly in mtd_info the offset of the partition, we
      can get rid of the mtd_part structure.
      
      While at it, be consistent in the naming of the mtd_info structures to
      ease the understanding of the new hierarchy: these structures are
      usually called 'mtd', unless there are multiple instances of the same
      structure. In this case, there is usually a parent/child bound so we
      will call them 'parent' and 'child'.
      Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      Link: https://lore.kernel.org/linux-mtd/20200114090952.11232-1-miquel.raynal@bootlin.com
      46b5889c
  18. 14 Nov, 2019 1 commit
  19. 29 Aug, 2019 1 commit
  20. 27 Jun, 2019 1 commit
  21. 24 May, 2019 1 commit
  22. 13 Feb, 2019 1 commit
  23. 29 Jan, 2019 1 commit
  24. 16 Jan, 2019 1 commit
  25. 07 Jan, 2019 1 commit
  26. 06 Dec, 2018 1 commit
  27. 02 Dec, 2018 2 commits
    • Rafał Miłecki's avatar
      mtd: keep original flags for every struct mtd_info · 1186af45
      Rafał Miłecki authored
      When allocating a new partition mtd subsystem runs internal tests in the
      allocate_partition(). They may result in modifying specified flags (e.g.
      dropping some /features/ like write access).
      
      Those constraints don't have to be necessary true for subpartitions. It
      may happen parent partition isn't block aligned (effectively disabling
      write access) while subpartition may fit blocks nicely. In such case all
      checks should be run again (starting with original flags value).
      Signed-off-by: default avatarRafał Miłecki <rafal@milecki.pl>
      Signed-off-by: default avatarBoris Brezillon <boris.brezillon@bootlin.com>
      1186af45
    • Miquel Raynal's avatar
      mtd: fix Coverity integer handling issue · 89f706db
      Miquel Raynal authored
      A Coverity robot reported an integer handling issue
      (OVERFLOW_BEFORE_WIDEN) in the potentially overflowing expression:
      
          (mtd_div_by_ws(mtd->size, mtd) - mtd_div_by_ws(offs, mtd)) *
          mtd_oobavail(mtd, ops)
      
      While such overflow will certainly never happen due to the numbers
      handled, it is cleaner to fix this operation anyway.
      
      The problem is that all the maths include 32-bit quantities, while the
      result is stored in an explicit 64-bit value.
      
      As maxooblen will just be compared with a size_t, let's change the
      type of the variable to a size_t. This will not fix anything but will
      clarify a bit the situation. Then, do an explicit cast to fix Coverity
      warning.
      Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      Signed-off-by: default avatarBoris Brezillon <boris.brezillon@bootlin.com>
      89f706db
  28. 18 Jul, 2018 1 commit
    • Miquel Raynal's avatar
      mtd: Fallback to ->_read/write() when ->_read/write_oob() is missing · 89fd23ef
      Miquel Raynal authored
      Some MTD sublayers/drivers are implementing ->_read/write() and
      not ->_read/write_oob().
      
      While for NAND devices both are usually valid, for NOR devices, using
      the _oob variant has no real meaning. But, as the MTD layer is supposed
      to hide as much as possible the flash complexity to the user, there is
      no reason to error out while it is just a matter of rewritting things
      internally.
      
      Add a fallback on mtd->_read() (resp. mtd->_write()) when the user calls
      mtd_read_oob() (resp. mtd_write_oob()) while mtd->_read_oob() (resp.
      mtd->_write_oob) is not implemented. There is already a fallback on the
      _oob variant if the former is used.
      Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      Signed-off-by: default avatarBoris Brezillon <boris.brezillon@bootlin.com>
      89fd23ef
  29. 16 May, 2018 1 commit
  30. 07 May, 2018 1 commit
    • Rafał Miłecki's avatar
      mtd: move code adding (registering) partitions to the parse_mtd_partitions() · 5ac67ce3
      Rafał Miłecki authored
      This commit slightly simplifies the code. Every parse_mtd_partitions()
      caller (out of two existing ones) had to add partitions & cleanup parser
      on its own. This moves that responsibility into the function.
      
      That change also allows dropping struct mtd_partitions argument.
      
      There is one minor behavior change caused by this cleanup. If
      parse_mtd_partitions() fails to add partitions (add_mtd_partitions()
      return an error) then mtd_device_parse_register() will still try to
      add (register) fallback partitions. It's a real corner case affecting
      one of uncommon error paths and shouldn't cause any harm.
      Signed-off-by: default avatarRafał Miłecki <rafal@milecki.pl>
      Signed-off-by: default avatarBoris Brezillon <boris.brezillon@bootlin.com>
      5ac67ce3
  31. 22 Apr, 2018 1 commit