<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/drivers/mtd/mtd_blkdevs.c, branch v3.0.72</title>
<subtitle>Linux kernel source tree</subtitle>
<id>https://git.amat.us/linux/atom/drivers/mtd/mtd_blkdevs.c?h=v3.0.72</id>
<link rel='self' href='https://git.amat.us/linux/atom/drivers/mtd/mtd_blkdevs.c?h=v3.0.72'/>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/'/>
<updated>2012-01-26T01:24:32Z</updated>
<entry>
<title>mtd: mtd_blkdevs: don't increase 'open' count on error path</title>
<updated>2012-01-26T01:24:32Z</updated>
<author>
<name>Brian Norris</name>
<email>computersforpeace@gmail.com</email>
</author>
<published>2011-11-07T23:51:05Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=488e572df737befdfc783503642d70ea18b3a001'/>
<id>urn:sha1:488e572df737befdfc783503642d70ea18b3a001</id>
<content type='text'>
commit 342ff28f5a2e5aa3236617bd2bddf6c749677ef2 upstream.

Some error paths in mtd_blkdevs were fixed in the following commit:

    commit 94735ec4044a6d318b83ad3c5794e931ed168d10
    mtd: mtd_blkdevs: fix error path in blktrans_open

But on these error paths, the block device's `dev-&gt;open' count is
already incremented before we check for errors. This meant that, while
the error path was handled correctly on the first time through
blktrans_open(), the device is erroneously considered already open on
the second time through.

This problem can be seen, for instance, when a UBI volume is
simultaneously mounted as a UBIFS partition and read through its
corresponding gluebi mtdblockX device. This results in blktrans_open()
passing its error checks (with `dev-&gt;open &gt; 0') without actually having
a handle on the device. Here's a summarized log of the actions and
results with nandsim:

    # modprobe nandsim
    # modprobe mtdblock
    # modprobe gluebi
    # modprobe ubifs
    # ubiattach /dev/ubi_ctrl -m 0
    ...
    # ubimkvol /dev/ubi0 -N test -s 16MiB
    ...
    # mount -t ubifs ubi0:test /mnt
    # ls /dev/mtdblock*
    /dev/mtdblock0  /dev/mtdblock1
    # cat /dev/mtdblock1 &gt; /dev/null
    cat: can't open '/dev/mtdblock4': Device or resource busy
    # cat /dev/mtdblock1 &gt; /dev/null

    CPU 0 Unable to handle kernel paging request at virtual address
    fffffff0, epc == 8031536c, ra == 8031f280
    Oops[#1]:
    ...
    Call Trace:
    [&lt;8031536c&gt;] ubi_leb_read+0x14/0x164
    [&lt;8031f280&gt;] gluebi_read+0xf0/0x148
    [&lt;802edba8&gt;] mtdblock_readsect+0x64/0x198
    [&lt;802ecfe4&gt;] mtd_blktrans_thread+0x330/0x3f4
    [&lt;8005be98&gt;] kthread+0x88/0x90
    [&lt;8000bc04&gt;] kernel_thread_helper+0x10/0x18

Signed-off-by: Brian Norris &lt;computersforpeace@gmail.com&gt;
Signed-off-by: Artem Bityutskiy &lt;Artem.Bityutskiy@linux.intel.com&gt;
Signed-off-by: David Woodhouse &lt;David.Woodhouse@intel.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;

</content>
</entry>
<entry>
<title>mtd: mtd_blkdevs: fix error path in blktrans_open</title>
<updated>2011-05-25T00:53:45Z</updated>
<author>
<name>Artem Bityutskiy</name>
<email>Artem.Bityutskiy@nokia.com</email>
</author>
<published>2011-04-18T04:50:37Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=94735ec4044a6d318b83ad3c5794e931ed168d10'/>
<id>urn:sha1:94735ec4044a6d318b83ad3c5794e931ed168d10</id>
<content type='text'>
The 'blktrans_open()' does not handle possible '__get_mtd_device()' failures
because it does not check the error code. Moreover, the 'dev-&gt;tr-&gt;open()'
failures are not handled correctly because in this case the function just
goes ahead and gets the mtd device, then returns an error. But Instead, it
should _not_ try to get the mtd device, then it should put back the module
and the kref.

This patch fixes the issue. Note, I only compile-tested it. This patch was
inspired by a bug report about a similar issue in 2.6.34 kernels
sent by Mike Turner &lt;admin@islandsoftware.co.uk&gt; to the MTD mailing list:

http://lists.infradead.org/pipermail/linux-mtd/2011-April/034980.html

Signed-off-by: Artem Bityutskiy &lt;Artem.Bityutskiy@nokia.com&gt;
Signed-off-by: David Woodhouse &lt;David.Woodhouse@intel.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6 into for-linus-1</title>
<updated>2011-03-25T15:41:20Z</updated>
<author>
<name>Artem Bityutskiy</name>
<email>Artem.Bityutskiy@nokia.com</email>
</author>
<published>2011-03-25T15:41:20Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=7bf7e370d5919112c223a269462cd0b546903829'/>
<id>urn:sha1:7bf7e370d5919112c223a269462cd0b546903829</id>
<content type='text'>
* 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6: (9356 commits)
  [media] rc: update for bitop name changes
  fs: simplify iget &amp; friends
  fs: pull inode-&gt;i_lock up out of writeback_single_inode
  fs: rename inode_lock to inode_hash_lock
  fs: move i_wb_list out from under inode_lock
  fs: move i_sb_list out from under inode_lock
  fs: remove inode_lock from iput_final and prune_icache
  fs: Lock the inode LRU list separately
  fs: factor inode disposal
  fs: protect inode-&gt;i_state with inode-&gt;i_lock
  lib, arch: add filter argument to show_mem and fix private implementations
  SLUB: Write to per cpu data when allocating it
  slub: Fix debugobjects with lockless fastpath
  autofs4: Do not potentially dereference NULL pointer returned by fget() in autofs_dev_ioctl_setpipefd()
  autofs4 - remove autofs4_lock
  autofs4 - fix d_manage() return on rcu-walk
  autofs4 - fix autofs4_expire_indirect() traversal
  autofs4 - fix dentry leak in autofs4_expire_direct()
  autofs4 - reinstate last used update on access
  vfs - check non-mountpoint dentry might block in __follow_mount_rcu()
  ...

NOTE!

This merge commit was created to fix compilation error. The block
tree was merged upstream and removed the 'elv_queue_empty()'
function which the new 'mtdswap' driver is using. So a simple
merge of the mtd tree with upstream does not compile. And the
mtd tree has already be published, so re-basing it is not an option.

To fix this unfortunate situation, I had to merge upstream into the
mtd-2.6.git tree without committing, put the fixup patch on top of
this, and then commit this. The result is that we do not have commits
which do not compile.

In other words, this merge commit "merges" 3 things: the MTD tree, the
upstream tree, and the fixup patch.
</content>
</entry>
<entry>
<title>mtd_blkdevs: Set the maximum discards size</title>
<updated>2011-03-11T14:22:46Z</updated>
<author>
<name>Jarkko Lavinen</name>
<email>jarkko.lavinen@nokia.com</email>
</author>
<published>2011-02-14T14:16:10Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=115ee88c15b55859a8b59c5dccb3882bbd47e542'/>
<id>urn:sha1:115ee88c15b55859a8b59c5dccb3882bbd47e542</id>
<content type='text'>
Set max_discard_sectors to UINT_MAX.

Signed-off-by: Jarkko Lavinen &lt;jarkko.lavinen@nokia.com&gt;
Tested-by: Artem Bityutskiy &lt;Artem.Bityutskiy@nokia.com&gt;
Signed-off-by: David Woodhouse &lt;David.Woodhouse@intel.com&gt;
</content>
</entry>
<entry>
<title>mtd_blkdevs: Add background processing support</title>
<updated>2011-03-11T14:22:46Z</updated>
<author>
<name>Jarkko Lavinen</name>
<email>jarkko.lavinen@nokia.com</email>
</author>
<published>2011-02-14T14:16:09Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=c7519dbf6f4b4408229d279d799c938ffdd06f21'/>
<id>urn:sha1:c7519dbf6f4b4408229d279d799c938ffdd06f21</id>
<content type='text'>
Add a new background method into mtd_blktrans_ops, add background support
into mtd_blktrans_thread(), and add mtd_blktrans_cease_background().

If the mtd blktrans dev has the background support, the thread will
call background function when the request queue becomes empty. The background
operation may run as long as needs to until
mtd_blktrans_cease_background() tells to stop.

Signed-off-by: Jarkko Lavinen &lt;jarkko.lavinen@nokia.com&gt;
Tested-by: Artem Bityutskiy &lt;Artem.Bityutskiy@nokia.com&gt;
Signed-off-by: David Woodhouse &lt;David.Woodhouse@intel.com&gt;
</content>
</entry>
<entry>
<title>mtd: mtd_blkdevs: local symbols should be static</title>
<updated>2011-03-11T14:22:42Z</updated>
<author>
<name>H Hartley Sweeten</name>
<email>hartleys@visionengravers.com</email>
</author>
<published>2011-01-12T00:46:10Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=7f53f12f02b0b60af373a07fcac62b578381308e'/>
<id>urn:sha1:7f53f12f02b0b60af373a07fcac62b578381308e</id>
<content type='text'>
The function blktrans_dev_release and blktrans_dev_put are only used
locally in this file and should be static.

Signed-off-by: H Hartley Sweeten &lt;hsweeten@visionengravers.com&gt;
Signed-off-by: Artem Bityutskiy &lt;Artem.Bityutskiy@nokia.com&gt;
Signed-off-by: David Woodhouse &lt;David.Woodhouse@intel.com&gt;
</content>
</entry>
<entry>
<title>mtd: mtd_blkdevs: fix double free on error path</title>
<updated>2011-03-11T14:19:44Z</updated>
<author>
<name>Maxim Levitsky</name>
<email>maximlevitsky@gmail.com</email>
</author>
<published>2011-01-08T23:25:06Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=bd637f6f22235b4613f9ab6555e8088a455c1ed4'/>
<id>urn:sha1:bd637f6f22235b4613f9ab6555e8088a455c1ed4</id>
<content type='text'>
This one liner patch fixes double free that will occur if add_mtd_blktrans_dev
fails. On failure it frees the input argument, but all its users also free it
on error which is natural thing to do. Thus don't free it.

All credit for finding that bug belongs to reporters of the bug in the android bugzilla
http://code.google.com/p/android/issues/detail?id=13761

Commit message tweaked by Artem.

Signed-off-by: Maxim Levitsky &lt;maximlevitsky@gmail.com&gt;
Signed-off-by: Artem Bityutskiy &lt;Artem.Bityutskiy@nokia.com&gt;
Signed-off-by: David Woodhouse &lt;David.Woodhouse@intel.com&gt;
Cc: stable@kernel.org
</content>
</entry>
<entry>
<title>mtd: Remove redundant mutex from mtd_blkdevs.c</title>
<updated>2010-10-30T11:39:21Z</updated>
<author>
<name>David Woodhouse</name>
<email>David.Woodhouse@intel.com</email>
</author>
<published>2010-10-30T11:39:21Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=8cc9de3ebdf654601db51a516267dff89c49acc3'/>
<id>urn:sha1:8cc9de3ebdf654601db51a516267dff89c49acc3</id>
<content type='text'>
In commit 2a48fc0ab24241755dc93bfd4f01d68efab47f5a ('block: autoconvert
trivial BKL users to private mutex'), Arnd replaced the BKL usage with a
mutex. However, Maxim has already provided a better fix in commit
480792b7bf188c29b8d4b10fee65c3a06ec5dbf7 ('mtd: blktrans: kill BKL'),
which was simply to remove the BKL without replacing it — since he'd
already made it do all necessary locking for itself.

Signed-off-by: David Woodhouse &lt;David.Woodhouse@intel.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git</title>
<updated>2010-10-30T11:35:11Z</updated>
<author>
<name>David Woodhouse</name>
<email>David.Woodhouse@intel.com</email>
</author>
<published>2010-10-30T11:35:11Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=67577927e8d7a1f4b09b4992df640eadc6aacb36'/>
<id>urn:sha1:67577927e8d7a1f4b09b4992df640eadc6aacb36</id>
<content type='text'>
Conflicts:
	drivers/mtd/mtd_blkdevs.c

Merge Grant's device-tree bits so that we can apply the subsequent fixes.

Signed-off-by: David Woodhouse &lt;David.Woodhouse@intel.com&gt;
</content>
</entry>
<entry>
<title>MTD: Fix wrong check register_blkdev return value</title>
<updated>2010-10-30T11:30:50Z</updated>
<author>
<name>Frank Li</name>
<email>Frank.Li@freescale.com</email>
</author>
<published>2010-10-26T03:02:19Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=6fe4c590313133ebd5dadb769031489ff178ece1'/>
<id>urn:sha1:6fe4c590313133ebd5dadb769031489ff178ece1</id>
<content type='text'>
register_blkdev return 1..255 when major = 0.

if (ret ) {
	printk(KERN_WARNING "Unable to register %s block device on major %d: %d\n",
		tr-&gt;name, tr-&gt;major, ret);
	      mutex_unlock(&amp;mtd_table_mutex);
	return ret;
}

Above code will return fail when register_blkdev return allocated major number.

Signed-off-by: Frank Li &lt;Frank.Li@freescale.com&gt;
Signed-off-by: David Woodhouse &lt;David.Woodhouse@intel.com&gt;
</content>
</entry>
</feed>
