<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/drivers/mtd, branch v5.14</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v5.14</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v5.14'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2021-08-16T16:36:01Z</updated>
<entry>
<title>Merge tag 'mtd/fixes-for-5.14-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux</title>
<updated>2021-08-16T16:36:01Z</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2021-08-16T16:36:01Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=a2824f19e6065a0d3735acd9fe7155b104e7edf5'/>
<id>urn:sha1:a2824f19e6065a0d3735acd9fe7155b104e7edf5</id>
<content type='text'>
Pull MTD fixes from Miquel Raynal:
 "MTD core fixes:
   - Fix lock hierarchy in deregister_mtd_blktrans
   - Handle flashes without OTP gracefully
   - Break circular locks in register_mtd_blktrans

  MTD device fixes:
   - mchp48l640:
      - Fix memory leak on cmd
      - Silence some uninitialized variable warnings
   - blkdevs:
      - Initialize rq.limits.discard_granularity

  CFI fixes:
   - Fix crash when erasing/writing AMD cards

  Raw NAND fixes:
   - Fix of_get_nand_secure_regions():
      - Add a missing check
      - Avoid an unwanted probe failure when a DT property is missing"

* tag 'mtd/fixes-for-5.14-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux:
  mtd: rawnand: Fix probe failure due to of_get_nand_secure_regions()
  mtd: fix lock hierarchy in deregister_mtd_blktrans
  mtd: devices: mchp48l640: Fix memory leak on cmd
  mtd: cfi_cmdset_0002: fix crash when erasing/writing AMD cards
  mtd: core: handle flashes without OTP gracefully
  mtd: mchp48l640: silence some uninitialized variable warnings
  mtd: break circular locks in register_mtd_blktrans
  mtd: rawnand: Add a check in of_get_nand_secure_regions()
  mtd: mtd_blkdevs: Initialize rq.limits.discard_granularity
</content>
</entry>
<entry>
<title>mtd: rawnand: Fix probe failure due to of_get_nand_secure_regions()</title>
<updated>2021-08-06T19:44:16Z</updated>
<author>
<name>Manivannan Sadhasivam</name>
<email>manivannan.sadhasivam@linaro.org</email>
</author>
<published>2021-07-27T06:28:13Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=b48027083a78b13356695555a05b0e085e378687'/>
<id>urn:sha1:b48027083a78b13356695555a05b0e085e378687</id>
<content type='text'>
Due to 14f97f0b8e2b, the rawnand platforms without "secure-regions"
property defined in DT fails to probe. The issue is,
of_get_nand_secure_regions() errors out if
of_property_count_elems_of_size() returns a negative error code.

If the "secure-regions" property is not present in DT, then also we'll
get -EINVAL from of_property_count_elems_of_size() but it should not
be treated as an error for platforms not declaring "secure-regions"
in DT.

So fix this behaviour by checking for the existence of that property in
DT and return 0 if it is not present.

Fixes: 14f97f0b8e2b ("mtd: rawnand: Add a check in of_get_nand_secure_regions()")
Reported-by: Martin Kaiser &lt;martin@kaiser.cx&gt;
Signed-off-by: Manivannan Sadhasivam &lt;manivannan.sadhasivam@linaro.org&gt;
Reviewed-by: Martin Kaiser &lt;martin@kaiser.cx&gt;
Tested-by: Martin Kaiser &lt;martin@kaiser.cx&gt;
Signed-off-by: Miquel Raynal &lt;miquel.raynal@bootlin.com&gt;
Link: https://lore.kernel.org/linux-mtd/20210727062813.32619-1-manivannan.sadhasivam@linaro.org
</content>
</entry>
<entry>
<title>mtd: fix lock hierarchy in deregister_mtd_blktrans</title>
<updated>2021-08-06T19:44:16Z</updated>
<author>
<name>Desmond Cheong Zhi Xi</name>
<email>desmondcheongzx@gmail.com</email>
</author>
<published>2021-07-17T10:07:19Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=b7abb051682263e51866bc78762fd0083d64c5ed'/>
<id>urn:sha1:b7abb051682263e51866bc78762fd0083d64c5ed</id>
<content type='text'>
There is a lock hierarchy of major_names_lock --&gt; mtd_table_mutex. One
existing chain is as follows:

1. major_names_lock --&gt; loop_ctl_mutex (when blk_request_module calls
loop_probe)

2. loop_ctl_mutex --&gt; bdev-&gt;bd_mutex (when loop_control_ioctl calls
loop_remove, which then calls del_gendisk)

3. bdev-&gt;bd_mutex --&gt; mtd_table_mutex (when blkdev_get_by_dev calls
__blkdev_get, which then calls blktrans_open)

Since unregister_blkdev grabs the major_names_lock, we need to call it
outside the critical section for mtd_table_mutex, otherwise we invert
the lock hierarchy.

Reported-by: Hillf Danton &lt;hdanton@sina.com&gt;
Signed-off-by: Desmond Cheong Zhi Xi &lt;desmondcheongzx@gmail.com&gt;
Signed-off-by: Miquel Raynal &lt;miquel.raynal@bootlin.com&gt;
Link: https://lore.kernel.org/linux-mtd/20210717100719.728829-1-desmondcheongzx@gmail.com
</content>
</entry>
<entry>
<title>mtd: devices: mchp48l640: Fix memory leak on cmd</title>
<updated>2021-08-06T19:44:09Z</updated>
<author>
<name>Colin Ian King</name>
<email>colin.king@canonical.com</email>
</author>
<published>2021-07-12T14:52:14Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=99dc4ad992bf156692b088fab4d98deab7cbd3e6'/>
<id>urn:sha1:99dc4ad992bf156692b088fab4d98deab7cbd3e6</id>
<content type='text'>
The allocation for cmd is not being kfree'd on the return leading to
a memory leak. Fix this by kfree'ing it.

Addresses-Coverity: ("Resource leak")
Fixes: 88d125026753 ("mtd: devices: add support for microchip 48l640 EERAM")
Signed-off-by: Colin Ian King &lt;colin.king@canonical.com&gt;
Reviewed-by: Heiko Schocher &lt;hs@denx.de&gt;
Signed-off-by: Miquel Raynal &lt;miquel.raynal@bootlin.com&gt;
Link: https://lore.kernel.org/linux-mtd/20210712145214.101377-1-colin.king@canonical.com
</content>
</entry>
<entry>
<title>mtd: cfi_cmdset_0002: fix crash when erasing/writing AMD cards</title>
<updated>2021-07-15T22:49:22Z</updated>
<author>
<name>Andreas Persson</name>
<email>andreasp56@outlook.com</email>
</author>
<published>2021-07-12T07:54:52Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=2394e628738933aa014093d93093030f6232946d'/>
<id>urn:sha1:2394e628738933aa014093d93093030f6232946d</id>
<content type='text'>
Erasing an AMD linear flash card (AM29F016D) crashes after the first
sector has been erased. Likewise, writing to it crashes after two bytes
have been written. The reason is a missing check for a null pointer -
the cmdset_priv field is not set for this type of card.

Fixes: 4844ef80305d ("mtd: cfi_cmdset_0002: Add support for polling status register")
Signed-off-by: Andreas Persson &lt;andreasp56@outlook.com&gt;
Signed-off-by: Miquel Raynal &lt;miquel.raynal@bootlin.com&gt;
Link: https://lore.kernel.org/linux-mtd/DB6P189MB05830B3530B8087476C5CFE4C1159@DB6P189MB0583.EURP189.PROD.OUTLOOK.COM
</content>
</entry>
<entry>
<title>mtd: core: handle flashes without OTP gracefully</title>
<updated>2021-07-15T22:49:20Z</updated>
<author>
<name>Michael Walle</name>
<email>michael@walle.cc</email>
</author>
<published>2021-07-07T13:53:59Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=45bb1faa29effbd4ca4d581b32373f2eda309b95'/>
<id>urn:sha1: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>
</entry>
<entry>
<title>mtd: mchp48l640: silence some uninitialized variable warnings</title>
<updated>2021-07-15T22:49:19Z</updated>
<author>
<name>Dan Carpenter</name>
<email>dan.carpenter@oracle.com</email>
</author>
<published>2021-06-18T13:42:07Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=e83862ee1b9b1668826683f432b041875ec0c819'/>
<id>urn:sha1:e83862ee1b9b1668826683f432b041875ec0c819</id>
<content type='text'>
Smatch complains that zero length read/writes will lead to an
uninitalized return value.  I don't know if that's possible, but
it's nicer to return a zero literal anyway so let's do that.

Fixes: 88d125026753 ("mtd: devices: add support for microchip 48l640 EERAM")
Signed-off-by: Dan Carpenter &lt;dan.carpenter@oracle.com&gt;
Reviewed-by: Fabio Estevam &lt;festevam@gmail.com&gt;
Reviewed-by: Heiko Schocher &lt;hs@denx.de&gt;
Signed-off-by: Miquel Raynal &lt;miquel.raynal@bootlin.com&gt;
Link: https://lore.kernel.org/linux-mtd/YMyir961W28TX5dT@mwanda
</content>
</entry>
<entry>
<title>mtd: break circular locks in register_mtd_blktrans</title>
<updated>2021-07-15T22:49:17Z</updated>
<author>
<name>Desmond Cheong Zhi Xi</name>
<email>desmondcheongzx@gmail.com</email>
</author>
<published>2021-06-17T16:09:04Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=962bf783ef65d15b0f8ca9c33342cf3b20bf0d2e'/>
<id>urn:sha1:962bf783ef65d15b0f8ca9c33342cf3b20bf0d2e</id>
<content type='text'>
Syzbot reported a circular locking dependency:
https://syzkaller.appspot.com/bug?id=7bd106c28e846d1023d4ca915718b1a0905444cb

This happens because of the following lock dependencies:

1. loop_ctl_mutex -&gt; bdev-&gt;bd_mutex (when loop_control_ioctl calls
loop_remove, which then calls del_gendisk; this also happens in
loop_exit which eventually calls loop_remove)

2. bdev-&gt;bd_mutex -&gt; mtd_table_mutex (when blkdev_get_by_dev calls
__blkdev_get, which then calls blktrans_open)

3. mtd_table_mutex -&gt; major_names_lock (when register_mtd_blktrans
calls __register_blkdev)

4. major_names_lock -&gt; loop_ctl_mutex (when blk_request_module calls
loop_probe)

Hence there's an overall dependency of:

loop_ctl_mutex   ----------&gt; bdev-&gt;bd_mutex
      ^                            |
      |                            |
      |                            v
major_names_lock &lt;---------  mtd_table_mutex

We can break this circular dependency by holding mtd_table_mutex only
for the required critical section in register_mtd_blktrans. This
avoids the mtd_table_mutex -&gt; major_names_lock dependency.

Reported-and-tested-by: syzbot+6a8a0d93c91e8fbf2e80@syzkaller.appspotmail.com
Co-developed-by: Christoph Hellwig &lt;hch@lst.de&gt;
Signed-off-by: Christoph Hellwig &lt;hch@lst.de&gt;
Signed-off-by: Desmond Cheong Zhi Xi &lt;desmondcheongzx@gmail.com&gt;
Signed-off-by: Miquel Raynal &lt;miquel.raynal@bootlin.com&gt;
Link: https://lore.kernel.org/linux-mtd/20210617160904.570111-1-desmondcheongzx@gmail.com
</content>
</entry>
<entry>
<title>mtd: rawnand: Add a check in of_get_nand_secure_regions()</title>
<updated>2021-07-15T22:49:15Z</updated>
<author>
<name>Dan Carpenter</name>
<email>dan.carpenter@oracle.com</email>
</author>
<published>2021-06-17T13:37:25Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=14f97f0b8e2b9950c028d0cb7311ffe26a3cc1c0'/>
<id>urn:sha1:14f97f0b8e2b9950c028d0cb7311ffe26a3cc1c0</id>
<content type='text'>
Check for whether of_property_count_elems_of_size() returns a negative
error code.

Fixes: 13b89768275d ("mtd: rawnand: Add support for secure regions in NAND memory")
Signed-off-by: Dan Carpenter &lt;dan.carpenter@oracle.com&gt;
Reviewed-by: Manivannan Sadhasivam &lt;mani@kernel.org&gt;
Signed-off-by: Miquel Raynal &lt;miquel.raynal@bootlin.com&gt;
Link: https://lore.kernel.org/linux-mtd/YMtQFXE0F1w7mUh+@mwanda
</content>
</entry>
<entry>
<title>mtd: mtd_blkdevs: Initialize rq.limits.discard_granularity</title>
<updated>2021-07-15T22:49:13Z</updated>
<author>
<name>Zhihao Cheng</name>
<email>chengzhihao1@huawei.com</email>
</author>
<published>2021-06-15T09:39:05Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=2b6d2833cd1d8a43a837a45da65860ef086443dc'/>
<id>urn:sha1:2b6d2833cd1d8a43a837a45da65860ef086443dc</id>
<content type='text'>
Since commit b35fd7422c2f8("block: check queue's limits.discard_granularity
in __blkdev_issue_discard()") checks rq.limits.discard_granularity in
__blkdev_issue_discard(), we may get following warnings on formatted ftl:

  WARNING: CPU: 2 PID: 7313 at block/blk-lib.c:51
  __blkdev_issue_discard+0x2a7/0x390

Reproducer:
  1. ftl_format /dev/mtd0
  2. modprobe ftl
  3. mkfs.vfat /dev/ftla
  4. mount -odiscard /dev/ftla temp
  5. dd if=/dev/zero of=temp/tst bs=1M count=10 oflag=direct
  6. dd if=/dev/zero of=temp/tst bs=1M count=10 oflag=direct

Fix it by initializing rq.limits.discard_granularity if device supports
discard operation.

Signed-off-by: Zhihao Cheng &lt;chengzhihao1@huawei.com&gt;
Signed-off-by: Miquel Raynal &lt;miquel.raynal@bootlin.com&gt;
Link: https://lore.kernel.org/linux-mtd/20210615093905.3473709-1-chengzhihao1@huawei.com
</content>
</entry>
</feed>
