<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux.git/drivers/mtd/mtdcore.c, branch v5.16</title>
<subtitle>Linux kernel source tree</subtitle>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/'/>
<entry>
<title>Merge tag 'mtd/for-5.16' of git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux</title>
<updated>2021-11-08T19:37:39+00:00</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2021-11-08T19:37:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=206825f50f908771934e1fba2bfc2e1f1138b36a'/>
<id>206825f50f908771934e1fba2bfc2e1f1138b36a</id>
<content type='text'>
Pull mtd updates from Miquel Raynal:
 "Core:
   - Remove obsolete macros only used by the old nand_ecclayout struct
   - Don't remove debugfs directory if device is in use
   - MAINTAINERS:
      - Add entry for Qualcomm NAND controller driver
      - Update the devicetree documentation path of hyperbus

  MTD devices:
   - block2mtd:
      - Add support for an optional custom MTD label
      - Minor refactor to avoid hard coded constant
   - mtdswap: Remove redundant assignment of pointer eb

  CFI:
   - Fixup CFI on ixp4xx

  Raw NAND controller drivers:
   - Arasan:
      - Prevent an unsupported configuration
   - Xway, Socrates: plat_nand, Pasemi, Orion, mpc5121, GPIO, Au1550nd,
     AMS-Delta:
      - Keep the driver compatible with on-die ECC engines
   - cs553x, lpc32xx_slc, ndfc, sharpsl, tmio, txx9ndfmc:
      - Revert the commits: "Fix external use of SW Hamming ECC helper"
      - And let callers use the bare Hamming helpers
   - Fsmc: Fix use of SM ORDER
   - Intel:
      - Fix potential buffer overflow in probe
   - xway, vf610, txx9ndfm, tegra, stm32, plat_nand, oxnas, omap, mtk,
     hisi504, gpmi, gpio, denali, bcm6368, atmel:
      - Make use of the helper function devm_platform_ioremap_resource{,byname}()

  Onenand drivers:
   - Samsung: Drop Exynos4 and describe driver in KConfig

  Raw NAND chip drivers:
   - Hynix: Add support for H27UCG8T2ETR-BC MLC NAND

  SPI NOR core:
   - Add spi-nor device tree binding under SPI NOR maintainers

  SPI NOR manufacturer drivers:
   - Enable locking for n25q128a13

  SPI NOR controller drivers:
   - Use devm_platform_ioremap_resource_byname()"

* tag 'mtd/for-5.16' of git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux: (50 commits)
  mtd: core: don't remove debugfs directory if device is in use
  MAINTAINERS: Update the devicetree documentation path of hyperbus
  mtd: block2mtd: add support for an optional custom MTD label
  mtd: block2mtd: minor refactor to avoid hard coded constant
  mtd: fixup CFI on ixp4xx
  mtd: rawnand: arasan: Prevent an unsupported configuration
  MAINTAINERS: Add entry for Qualcomm NAND controller driver
  mtd: rawnand: hynix: Add support for H27UCG8T2ETR-BC MLC NAND
  mtd: rawnand: xway: Keep the driver compatible with on-die ECC engines
  mtd: rawnand: socrates: Keep the driver compatible with on-die ECC engines
  mtd: rawnand: plat_nand: Keep the driver compatible with on-die ECC engines
  mtd: rawnand: pasemi: Keep the driver compatible with on-die ECC engines
  mtd: rawnand: orion: Keep the driver compatible with on-die ECC engines
  mtd: rawnand: mpc5121: Keep the driver compatible with on-die ECC engines
  mtd: rawnand: gpio: Keep the driver compatible with on-die ECC engines
  mtd: rawnand: au1550nd: Keep the driver compatible with on-die ECC engines
  mtd: rawnand: ams-delta: Keep the driver compatible with on-die ECC engines
  Revert "mtd: rawnand: cs553x: Fix external use of SW Hamming ECC helper"
  Revert "mtd: rawnand: lpc32xx_slc: Fix external use of SW Hamming ECC helper"
  Revert "mtd: rawnand: ndfc: Fix external use of SW Hamming ECC helper"
  ...
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Pull mtd updates from Miquel Raynal:
 "Core:
   - Remove obsolete macros only used by the old nand_ecclayout struct
   - Don't remove debugfs directory if device is in use
   - MAINTAINERS:
      - Add entry for Qualcomm NAND controller driver
      - Update the devicetree documentation path of hyperbus

  MTD devices:
   - block2mtd:
      - Add support for an optional custom MTD label
      - Minor refactor to avoid hard coded constant
   - mtdswap: Remove redundant assignment of pointer eb

  CFI:
   - Fixup CFI on ixp4xx

  Raw NAND controller drivers:
   - Arasan:
      - Prevent an unsupported configuration
   - Xway, Socrates: plat_nand, Pasemi, Orion, mpc5121, GPIO, Au1550nd,
     AMS-Delta:
      - Keep the driver compatible with on-die ECC engines
   - cs553x, lpc32xx_slc, ndfc, sharpsl, tmio, txx9ndfmc:
      - Revert the commits: "Fix external use of SW Hamming ECC helper"
      - And let callers use the bare Hamming helpers
   - Fsmc: Fix use of SM ORDER
   - Intel:
      - Fix potential buffer overflow in probe
   - xway, vf610, txx9ndfm, tegra, stm32, plat_nand, oxnas, omap, mtk,
     hisi504, gpmi, gpio, denali, bcm6368, atmel:
      - Make use of the helper function devm_platform_ioremap_resource{,byname}()

  Onenand drivers:
   - Samsung: Drop Exynos4 and describe driver in KConfig

  Raw NAND chip drivers:
   - Hynix: Add support for H27UCG8T2ETR-BC MLC NAND

  SPI NOR core:
   - Add spi-nor device tree binding under SPI NOR maintainers

  SPI NOR manufacturer drivers:
   - Enable locking for n25q128a13

  SPI NOR controller drivers:
   - Use devm_platform_ioremap_resource_byname()"

* tag 'mtd/for-5.16' of git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux: (50 commits)
  mtd: core: don't remove debugfs directory if device is in use
  MAINTAINERS: Update the devicetree documentation path of hyperbus
  mtd: block2mtd: add support for an optional custom MTD label
  mtd: block2mtd: minor refactor to avoid hard coded constant
  mtd: fixup CFI on ixp4xx
  mtd: rawnand: arasan: Prevent an unsupported configuration
  MAINTAINERS: Add entry for Qualcomm NAND controller driver
  mtd: rawnand: hynix: Add support for H27UCG8T2ETR-BC MLC NAND
  mtd: rawnand: xway: Keep the driver compatible with on-die ECC engines
  mtd: rawnand: socrates: Keep the driver compatible with on-die ECC engines
  mtd: rawnand: plat_nand: Keep the driver compatible with on-die ECC engines
  mtd: rawnand: pasemi: Keep the driver compatible with on-die ECC engines
  mtd: rawnand: orion: Keep the driver compatible with on-die ECC engines
  mtd: rawnand: mpc5121: Keep the driver compatible with on-die ECC engines
  mtd: rawnand: gpio: Keep the driver compatible with on-die ECC engines
  mtd: rawnand: au1550nd: Keep the driver compatible with on-die ECC engines
  mtd: rawnand: ams-delta: Keep the driver compatible with on-die ECC engines
  Revert "mtd: rawnand: cs553x: Fix external use of SW Hamming ECC helper"
  Revert "mtd: rawnand: lpc32xx_slc: Fix external use of SW Hamming ECC helper"
  Revert "mtd: rawnand: ndfc: Fix external use of SW Hamming ECC helper"
  ...
</pre>
</div>
</content>
</entry>
<entry>
<title>mtd: call bdi_unregister explicitly</title>
<updated>2021-11-06T20:30:34+00:00</updated>
<author>
<name>Christoph Hellwig</name>
<email>hch@lst.de</email>
</author>
<published>2021-11-05T20:36:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=9718c59c0a1604350c06ffd87d598f03dcf5e9ca'/>
<id>9718c59c0a1604350c06ffd87d598f03dcf5e9ca</id>
<content type='text'>
Call bdi_unregister explicitly instead of relying on the automatic
unregistration.

Link: https://lkml.kernel.org/r/20211021124441.668816-3-hch@lst.de
Signed-off-by: Christoph Hellwig &lt;hch@lst.de&gt;
Reviewed-by: Jan Kara &lt;jack@suse.cz&gt;
Cc: Miquel Raynal &lt;miquel.raynal@bootlin.com&gt;
Cc: Richard Weinberger &lt;richard@nod.at&gt;
Cc: Vignesh Raghavendra &lt;vigneshr@ti.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Call bdi_unregister explicitly instead of relying on the automatic
unregistration.

Link: https://lkml.kernel.org/r/20211021124441.668816-3-hch@lst.de
Signed-off-by: Christoph Hellwig &lt;hch@lst.de&gt;
Reviewed-by: Jan Kara &lt;jack@suse.cz&gt;
Cc: Miquel Raynal &lt;miquel.raynal@bootlin.com&gt;
Cc: Richard Weinberger &lt;richard@nod.at&gt;
Cc: Vignesh Raghavendra &lt;vigneshr@ti.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>mtd: core: don't remove debugfs directory if device is in use</title>
<updated>2021-10-15T10:30:40+00:00</updated>
<author>
<name>Zev Weiss</name>
<email>zev@bewilderbeest.net</email>
</author>
<published>2021-10-14T20:39:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=c13de2386c78e890d4ae6f01a85eefd0b293fb08'/>
<id>c13de2386c78e890d4ae6f01a85eefd0b293fb08</id>
<content type='text'>
Previously, if del_mtd_device() failed with -EBUSY due to a non-zero
usecount, a subsequent call to attempt the deletion again would try to
remove a debugfs directory that had already been removed and panic.
With this change the second call can instead proceed safely.

Fixes: e8e3edb95ce6 ("mtd: create per-device and module-scope debugfs entries")
Signed-off-by: Zev Weiss &lt;zev@bewilderbeest.net&gt;
Signed-off-by: Miquel Raynal &lt;miquel.raynal@bootlin.com&gt;
Link: https://lore.kernel.org/linux-mtd/20211014203953.5424-1-zev@bewilderbeest.net
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Previously, if del_mtd_device() failed with -EBUSY due to a non-zero
usecount, a subsequent call to attempt the deletion again would try to
remove a debugfs directory that had already been removed and panic.
With this change the second call can instead proceed safely.

Fixes: e8e3edb95ce6 ("mtd: create per-device and module-scope debugfs entries")
Signed-off-by: Zev Weiss &lt;zev@bewilderbeest.net&gt;
Signed-off-by: Miquel Raynal &lt;miquel.raynal@bootlin.com&gt;
Link: https://lore.kernel.org/linux-mtd/20211014203953.5424-1-zev@bewilderbeest.net
</pre>
</div>
</content>
</entry>
<entry>
<title>mtd: core: handle flashes without OTP gracefully</title>
<updated>2021-07-15T22:49:20+00:00</updated>
<author>
<name>Michael Walle</name>
<email>michael@walle.cc</email>
</author>
<published>2021-07-07T13:53:59+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=45bb1faa29effbd4ca4d581b32373f2eda309b95'/>
<id>45bb1faa29effbd4ca4d581b32373f2eda309b95</id>
<content type='text'>
There are flash drivers which registers the OTP callbacks although the
flash doesn't support OTP regions and return -ENODATA for these
callbacks if there is no OTP. If this happens, the probe of the whole
flash will fail. Fix it by handling the ENODATA return code and skip
the OTP region nvmem setup.

Fixes: 4b361cfa8624 ("mtd: core: add OTP nvmem provider support")
Reported-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Signed-off-by: Michael Walle &lt;michael@walle.cc&gt;
Tested-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Signed-off-by: Miquel Raynal &lt;miquel.raynal@bootlin.com&gt;
Link: https://lore.kernel.org/linux-mtd/20210707135359.32398-1-michael@walle.cc
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
There are flash drivers which registers the OTP callbacks although the
flash doesn't support OTP regions and return -ENODATA for these
callbacks if there is no OTP. If this happens, the probe of the whole
flash will fail. Fix it by handling the ENODATA return code and skip
the OTP region nvmem setup.

Fixes: 4b361cfa8624 ("mtd: core: add OTP nvmem provider support")
Reported-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Signed-off-by: Michael Walle &lt;michael@walle.cc&gt;
Tested-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Signed-off-by: Miquel Raynal &lt;miquel.raynal@bootlin.com&gt;
Link: https://lore.kernel.org/linux-mtd/20210707135359.32398-1-michael@walle.cc
</pre>
</div>
</content>
</entry>
<entry>
<title>mtd: core: use MTD_DEVICE_ATTR_RO/RW() helper macros</title>
<updated>2021-06-11T18:42:57+00:00</updated>
<author>
<name>Zhen Lei</name>
<email>thunder.leizhen@huawei.com</email>
</author>
<published>2021-06-03T12:53:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=a17da115ac042fd560cba2f8e4057722cf0c42cd'/>
<id>a17da115ac042fd560cba2f8e4057722cf0c42cd</id>
<content type='text'>
Use MTD_DEVICE_ATTR_RO/RW() helper macros instead of plain DEVICE_ATTR(),
which makes the code a bit shorter and easier to read.

Signed-off-by: Zhen Lei &lt;thunder.leizhen@huawei.com&gt;
Signed-off-by: Miquel Raynal &lt;miquel.raynal@bootlin.com&gt;
Link: https://lore.kernel.org/linux-mtd/20210603125323.12142-3-thunder.leizhen@huawei.com
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Use MTD_DEVICE_ATTR_RO/RW() helper macros instead of plain DEVICE_ATTR(),
which makes the code a bit shorter and easier to read.

Signed-off-by: Zhen Lei &lt;thunder.leizhen@huawei.com&gt;
Signed-off-by: Miquel Raynal &lt;miquel.raynal@bootlin.com&gt;
Link: https://lore.kernel.org/linux-mtd/20210603125323.12142-3-thunder.leizhen@huawei.com
</pre>
</div>
</content>
</entry>
<entry>
<title>mtd: core: add MTD_DEVICE_ATTR_RO/RW() helper macros</title>
<updated>2021-06-11T18:42:50+00:00</updated>
<author>
<name>Zhen Lei</name>
<email>thunder.leizhen@huawei.com</email>
</author>
<published>2021-06-03T12:53:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=b4e248632c968d985f0ecfd7924423fbefc39d1c'/>
<id>b4e248632c968d985f0ecfd7924423fbefc39d1c</id>
<content type='text'>
Compared with the definition of DEVICE_ATTR_RO/RW(), the read and write
function names of the sysfs attribute have an additional "mtd_" prefix.

Signed-off-by: Zhen Lei &lt;thunder.leizhen@huawei.com&gt;
Signed-off-by: Miquel Raynal &lt;miquel.raynal@bootlin.com&gt;
Link: https://lore.kernel.org/linux-mtd/20210603125323.12142-2-thunder.leizhen@huawei.com
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Compared with the definition of DEVICE_ATTR_RO/RW(), the read and write
function names of the sysfs attribute have an additional "mtd_" prefix.

Signed-off-by: Zhen Lei &lt;thunder.leizhen@huawei.com&gt;
Signed-off-by: Miquel Raynal &lt;miquel.raynal@bootlin.com&gt;
Link: https://lore.kernel.org/linux-mtd/20210603125323.12142-2-thunder.leizhen@huawei.com
</pre>
</div>
</content>
</entry>
<entry>
<title>mtd: core: Potential NULL dereference in mtd_otp_size()</title>
<updated>2021-05-26T08:41:43+00:00</updated>
<author>
<name>Dan Carpenter</name>
<email>dan.carpenter@oracle.com</email>
</author>
<published>2021-05-14T14:27:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=c3c8c051df3ee5042dd91593593a8b0e008f4c85'/>
<id>c3c8c051df3ee5042dd91593593a8b0e008f4c85</id>
<content type='text'>
If kmalloc() fails then it could lead to a NULL dereference.  Check and
return -ENOMEM on error.

Fixes: 4b361cfa8624 ("mtd: core: add OTP nvmem provider support")
Signed-off-by: Dan Carpenter &lt;dan.carpenter@oracle.com&gt;
Reviewed-by: Michael Walle &lt;michael@walle.cc&gt;
Signed-off-by: Miquel Raynal &lt;miquel.raynal@bootlin.com&gt;
Link: https://lore.kernel.org/linux-mtd/YJ6Iw3iNvGycAWV6@mwanda
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
If kmalloc() fails then it could lead to a NULL dereference.  Check and
return -ENOMEM on error.

Fixes: 4b361cfa8624 ("mtd: core: add OTP nvmem provider support")
Signed-off-by: Dan Carpenter &lt;dan.carpenter@oracle.com&gt;
Reviewed-by: Michael Walle &lt;michael@walle.cc&gt;
Signed-off-by: Miquel Raynal &lt;miquel.raynal@bootlin.com&gt;
Link: https://lore.kernel.org/linux-mtd/YJ6Iw3iNvGycAWV6@mwanda
</pre>
</div>
</content>
</entry>
<entry>
<title>mtd: core: Fix freeing of otp_info buffer</title>
<updated>2021-05-26T08:39:27+00:00</updated>
<author>
<name>Jon Hunter</name>
<email>jonathanh@nvidia.com</email>
</author>
<published>2021-05-18T18:55:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=bc8e157fdb466536557b97b6c0df6d7b46a2b91b'/>
<id>bc8e157fdb466536557b97b6c0df6d7b46a2b91b</id>
<content type='text'>
Commit 4b361cfa8624 ("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
 ...
 [&lt;c029bb1c&gt;] (___cache_free) from [&lt;c029c658&gt;] (kfree+0xac/0x1bc)
 [&lt;c029c658&gt;] (kfree) from [&lt;c06da094&gt;] (mtd_otp_size+0xc4/0x108)
 [&lt;c06da094&gt;] (mtd_otp_size) from [&lt;c06dc864&gt;] (mtd_device_parse_register+0xe4/0x2b4)
 [&lt;c06dc864&gt;] (mtd_device_parse_register) from [&lt;c06e3ccc&gt;] (spi_nor_probe+0x210/0x2c0)
 [&lt;c06e3ccc&gt;] (spi_nor_probe) from [&lt;c06e9578&gt;] (spi_probe+0x88/0xac)
 [&lt;c06e9578&gt;] (spi_probe) from [&lt;c066891c&gt;] (really_probe+0x214/0x3a4)
 [&lt;c066891c&gt;] (really_probe) from [&lt;c0668b14&gt;] (driver_probe_device+0x68/0xc0)
 [&lt;c0668b14&gt;] (driver_probe_device) from [&lt;c0666cf8&gt;] (bus_for_each_drv+0x5c/0xbc)
 [&lt;c0666cf8&gt;] (bus_for_each_drv) from [&lt;c0668694&gt;] (__device_attach+0xe4/0x150)
 [&lt;c0668694&gt;] (__device_attach) from [&lt;c06679e0&gt;] (bus_probe_device+0x84/0x8c)
 [&lt;c06679e0&gt;] (bus_probe_device) from [&lt;c06657f8&gt;] (device_add+0x48c/0x868)
 [&lt;c06657f8&gt;] (device_add) from [&lt;c06eb784&gt;] (spi_add_device+0xa0/0x168)
 [&lt;c06eb784&gt;] (spi_add_device) from [&lt;c06ec9a8&gt;] (spi_register_controller+0x8b8/0xb38)
 [&lt;c06ec9a8&gt;] (spi_register_controller) from [&lt;c06ecc3c&gt;] (devm_spi_register_controller+0x14/0x50)
 [&lt;c06ecc3c&gt;] (devm_spi_register_controller) from [&lt;c06f0510&gt;] (tegra_spi_probe+0x33c/0x450)
 [&lt;c06f0510&gt;] (tegra_spi_probe) from [&lt;c066abec&gt;] (platform_probe+0x5c/0xb8)
 [&lt;c066abec&gt;] (platform_probe) from [&lt;c066891c&gt;] (really_probe+0x214/0x3a4)
 [&lt;c066891c&gt;] (really_probe) from [&lt;c0668b14&gt;] (driver_probe_device+0x68/0xc0)
 [&lt;c0668b14&gt;] (driver_probe_device) from [&lt;c0668e30&gt;] (device_driver_attach+0x58/0x60)
 [&lt;c0668e30&gt;] (device_driver_attach) from [&lt;c0668eb8&gt;] (__driver_attach+0x80/0xc8)
 [&lt;c0668eb8&gt;] (__driver_attach) from [&lt;c0666c48&gt;] (bus_for_each_dev+0x78/0xb8)
 [&lt;c0666c48&gt;] (bus_for_each_dev) from [&lt;c0667c44&gt;] (bus_add_driver+0x164/0x1e8)
 [&lt;c0667c44&gt;] (bus_add_driver) from [&lt;c066997c&gt;] (driver_register+0x7c/0x114)
 [&lt;c066997c&gt;] (driver_register) from [&lt;c010223c&gt;] (do_one_initcall+0x50/0x2b0)
 [&lt;c010223c&gt;] (do_one_initcall) from [&lt;c11011f0&gt;] (kernel_init_freeable+0x1a8/0x1fc)
 [&lt;c11011f0&gt;] (kernel_init_freeable) from [&lt;c0c09190&gt;] (kernel_init+0x8/0x118)
 [&lt;c0c09190&gt;] (kernel_init) from [&lt;c01001b0&gt;] (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: 4b361cfa8624 ("mtd: core: add OTP nvmem provider support")
Signed-off-by: Jon Hunter &lt;jonathanh@nvidia.com&gt;
Reviewed-by: Michael Walle &lt;michael@walle.cc&gt;
Signed-off-by: Miquel Raynal &lt;miquel.raynal@bootlin.com&gt;
Link: https://lore.kernel.org/linux-mtd/20210518185503.162787-1-jonathanh@nvidia.com
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Commit 4b361cfa8624 ("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
 ...
 [&lt;c029bb1c&gt;] (___cache_free) from [&lt;c029c658&gt;] (kfree+0xac/0x1bc)
 [&lt;c029c658&gt;] (kfree) from [&lt;c06da094&gt;] (mtd_otp_size+0xc4/0x108)
 [&lt;c06da094&gt;] (mtd_otp_size) from [&lt;c06dc864&gt;] (mtd_device_parse_register+0xe4/0x2b4)
 [&lt;c06dc864&gt;] (mtd_device_parse_register) from [&lt;c06e3ccc&gt;] (spi_nor_probe+0x210/0x2c0)
 [&lt;c06e3ccc&gt;] (spi_nor_probe) from [&lt;c06e9578&gt;] (spi_probe+0x88/0xac)
 [&lt;c06e9578&gt;] (spi_probe) from [&lt;c066891c&gt;] (really_probe+0x214/0x3a4)
 [&lt;c066891c&gt;] (really_probe) from [&lt;c0668b14&gt;] (driver_probe_device+0x68/0xc0)
 [&lt;c0668b14&gt;] (driver_probe_device) from [&lt;c0666cf8&gt;] (bus_for_each_drv+0x5c/0xbc)
 [&lt;c0666cf8&gt;] (bus_for_each_drv) from [&lt;c0668694&gt;] (__device_attach+0xe4/0x150)
 [&lt;c0668694&gt;] (__device_attach) from [&lt;c06679e0&gt;] (bus_probe_device+0x84/0x8c)
 [&lt;c06679e0&gt;] (bus_probe_device) from [&lt;c06657f8&gt;] (device_add+0x48c/0x868)
 [&lt;c06657f8&gt;] (device_add) from [&lt;c06eb784&gt;] (spi_add_device+0xa0/0x168)
 [&lt;c06eb784&gt;] (spi_add_device) from [&lt;c06ec9a8&gt;] (spi_register_controller+0x8b8/0xb38)
 [&lt;c06ec9a8&gt;] (spi_register_controller) from [&lt;c06ecc3c&gt;] (devm_spi_register_controller+0x14/0x50)
 [&lt;c06ecc3c&gt;] (devm_spi_register_controller) from [&lt;c06f0510&gt;] (tegra_spi_probe+0x33c/0x450)
 [&lt;c06f0510&gt;] (tegra_spi_probe) from [&lt;c066abec&gt;] (platform_probe+0x5c/0xb8)
 [&lt;c066abec&gt;] (platform_probe) from [&lt;c066891c&gt;] (really_probe+0x214/0x3a4)
 [&lt;c066891c&gt;] (really_probe) from [&lt;c0668b14&gt;] (driver_probe_device+0x68/0xc0)
 [&lt;c0668b14&gt;] (driver_probe_device) from [&lt;c0668e30&gt;] (device_driver_attach+0x58/0x60)
 [&lt;c0668e30&gt;] (device_driver_attach) from [&lt;c0668eb8&gt;] (__driver_attach+0x80/0xc8)
 [&lt;c0668eb8&gt;] (__driver_attach) from [&lt;c0666c48&gt;] (bus_for_each_dev+0x78/0xb8)
 [&lt;c0666c48&gt;] (bus_for_each_dev) from [&lt;c0667c44&gt;] (bus_add_driver+0x164/0x1e8)
 [&lt;c0667c44&gt;] (bus_add_driver) from [&lt;c066997c&gt;] (driver_register+0x7c/0x114)
 [&lt;c066997c&gt;] (driver_register) from [&lt;c010223c&gt;] (do_one_initcall+0x50/0x2b0)
 [&lt;c010223c&gt;] (do_one_initcall) from [&lt;c11011f0&gt;] (kernel_init_freeable+0x1a8/0x1fc)
 [&lt;c11011f0&gt;] (kernel_init_freeable) from [&lt;c0c09190&gt;] (kernel_init+0x8/0x118)
 [&lt;c0c09190&gt;] (kernel_init) from [&lt;c01001b0&gt;] (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: 4b361cfa8624 ("mtd: core: add OTP nvmem provider support")
Signed-off-by: Jon Hunter &lt;jonathanh@nvidia.com&gt;
Reviewed-by: Michael Walle &lt;michael@walle.cc&gt;
Signed-off-by: Miquel Raynal &lt;miquel.raynal@bootlin.com&gt;
Link: https://lore.kernel.org/linux-mtd/20210518185503.162787-1-jonathanh@nvidia.com
</pre>
</div>
</content>
</entry>
<entry>
<title>mtd: Create partname and partid debug files for child MTDs</title>
<updated>2021-05-10T10:48:45+00:00</updated>
<author>
<name>Petr Malat</name>
<email>oss@malat.biz</email>
</author>
<published>2021-04-30T06:50:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=feb05fae4df10f6b9bf720662623efc88334c095'/>
<id>feb05fae4df10f6b9bf720662623efc88334c095</id>
<content type='text'>
Partname and partid are set by the upper driver (spi-nor) on the master
MTD. If this MTD is partitioned and CONFIG_MTD_PARTITIONED_MASTER is
disabled, the master MTD is not instantiated and partname and partid
aren't available to the userspace.

Always read the partname and partid from the master MTD, they describe
the HW, which can't differ between master and its children.

Signed-off-by: Petr Malat &lt;oss@malat.biz&gt;
Signed-off-by: Miquel Raynal &lt;miquel.raynal@bootlin.com&gt;
Link: https://lore.kernel.org/linux-mtd/20210430065057.32018-1-oss@malat.biz
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Partname and partid are set by the upper driver (spi-nor) on the master
MTD. If this MTD is partitioned and CONFIG_MTD_PARTITIONED_MASTER is
disabled, the master MTD is not instantiated and partname and partid
aren't available to the userspace.

Always read the partname and partid from the master MTD, they describe
the HW, which can't differ between master and its children.

Signed-off-by: Petr Malat &lt;oss@malat.biz&gt;
Signed-off-by: Miquel Raynal &lt;miquel.raynal@bootlin.com&gt;
Link: https://lore.kernel.org/linux-mtd/20210430065057.32018-1-oss@malat.biz
</pre>
</div>
</content>
</entry>
<entry>
<title>mtd: core: add OTP nvmem provider support</title>
<updated>2021-05-10T10:42:55+00:00</updated>
<author>
<name>Michael Walle</name>
<email>michael@walle.cc</email>
</author>
<published>2021-04-24T11:06:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=4b361cfa862479fbb1d14ddf01de4dbc7146dcc5'/>
<id>4b361cfa862479fbb1d14ddf01de4dbc7146dcc5</id>
<content type='text'>
Flash OTP regions can already be read via user space. Some boards have
their serial number or MAC addresses stored in the OTP regions. Add
support for them being a (read-only) nvmem provider.

The API to read the OTP data is already in place. It distinguishes
between factory and user OTP, thus there are up to two different
providers.

Signed-off-by: Michael Walle &lt;michael@walle.cc&gt;
Signed-off-by: Miquel Raynal &lt;miquel.raynal@bootlin.com&gt;
Link: https://lore.kernel.org/linux-mtd/20210424110608.15748-6-michael@walle.cc
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Flash OTP regions can already be read via user space. Some boards have
their serial number or MAC addresses stored in the OTP regions. Add
support for them being a (read-only) nvmem provider.

The API to read the OTP data is already in place. It distinguishes
between factory and user OTP, thus there are up to two different
providers.

Signed-off-by: Michael Walle &lt;michael@walle.cc&gt;
Signed-off-by: Miquel Raynal &lt;miquel.raynal@bootlin.com&gt;
Link: https://lore.kernel.org/linux-mtd/20210424110608.15748-6-michael@walle.cc
</pre>
</div>
</content>
</entry>
</feed>
