<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/git/stable/linux.git/drivers/mtd/mtdoops.c, branch master</title>
<subtitle>Linux kernel stable tree</subtitle>
<id>https://git.landau.one/pub/scm/linux/kernel/git/stable/linux.git/atom?h=master</id>
<link rel='self' href='https://git.landau.one/pub/scm/linux/kernel/git/stable/linux.git/atom?h=master'/>
<link rel='alternate' type='text/html' href='https://git.landau.one/pub/scm/linux/kernel/git/stable/linux.git/'/>
<updated>2026-07-17T15:49:27+00:00</updated>
<entry>
<title>mtd: mtdoops: free page bitmap when the backing MTD is removed</title>
<updated>2026-07-17T15:49:27+00:00</updated>
<author>
<name>Xu Rao</name>
<email>raoxu@uniontech.com</email>
</author>
<published>2026-07-13T05:22:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.landau.one/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=956e7da12c114f13c63d126ab1d79c3b6a819060'/>
<id>urn:sha1:956e7da12c114f13c63d126ab1d79c3b6a819060</id>
<content type='text'>
mtdoops_notify_add() allocates oops_page_used when the configured MTD
device is registered.  mtdoops_notify_remove() detaches from that device
but leaves the bitmap allocated.  If the same MTD device is later
registered again, the add path allocates a new bitmap and overwrites the
old pointer, leaking one vmalloc allocation per remove/add cycle.

This is only visible when the backing MTD device can disappear and be
registered again while mtdoops remains loaded, so the usual static MTD
case does not expose it.

Free the bitmap after unregistering the dumper and flushing the pending
workers, then clear the pointer and page count before a later attach can
allocate fresh state.  Clearing the pointer also keeps the module exit
path from freeing the same bitmap a second time after a remove event.

Fixes: be95745f0167 ("mtd: mtdoops: keep track of used/unused pages in an array")
Cc: stable@vger.kernel.org
Signed-off-by: Xu Rao &lt;raoxu@uniontech.com&gt;
Signed-off-by: Miquel Raynal &lt;miquel.raynal@bootlin.com&gt;
</content>
</entry>
<entry>
<title>mtd: mtdoops: replace simple_strtoul with kstrtouint</title>
<updated>2026-04-27T13:12:58+00:00</updated>
<author>
<name>Haoyu Lu</name>
<email>hechushiguitu666@gmail.com</email>
</author>
<published>2026-04-10T13:37:34+00:00</published>
<link rel='alternate' type='text/html' href='https://git.landau.one/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=6b07cdff176bc5f8fef459b85a7e2ea09e68543f'/>
<id>urn:sha1:6b07cdff176bc5f8fef459b85a7e2ea09e68543f</id>
<content type='text'>
Replace deprecated simple_strtoul with kstrtouint for better error
handling and type safety. The kstrtouint function provides stricter
validation, automatically rejecting inputs like "123abc" that
simple_strtoul would partially accept.

Using kstrtouint avoids unsigned long to int conversion and is more
appropriate for MTD device indices which are non-negative integers.

Signed-off-by: Haoyu Lu &lt;hechushiguitu666@gmail.com&gt;
Signed-off-by: Miquel Raynal &lt;miquel.raynal@bootlin.com&gt;
</content>
</entry>
<entry>
<title>mtd: use vmalloc_array and vcalloc to simplify code</title>
<updated>2025-09-11T15:34:15+00:00</updated>
<author>
<name>Qianfeng Rong</name>
<email>rongqianfeng@vivo.com</email>
</author>
<published>2025-08-12T03:58:53+00:00</published>
<link rel='alternate' type='text/html' href='https://git.landau.one/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=81eb13a19a8eb259b3d9b1fdf5cbf154f71fc1d0'/>
<id>urn:sha1:81eb13a19a8eb259b3d9b1fdf5cbf154f71fc1d0</id>
<content type='text'>
Remove array_size() calls and replace vmalloc(array_size()) with
vmalloc_array() and vzalloc(array_size()) with vcalloc() to simplify
the code.

Compile-tested only.

Signed-off-by: Qianfeng Rong &lt;rongqianfeng@vivo.com&gt;
Signed-off-by: Miquel Raynal &lt;miquel.raynal@bootlin.com&gt;
</content>
</entry>
<entry>
<title>mtd: mtdoops: Fix kmsgdump parameter renaming.</title>
<updated>2024-07-22T15:56:22+00:00</updated>
<author>
<name>Jocelyn Falempe</name>
<email>jfalempe@redhat.com</email>
</author>
<published>2024-07-19T15:24:13+00:00</published>
<link rel='alternate' type='text/html' href='https://git.landau.one/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=1f7ce4316d8c8ca8fdf5e477fee91012420b1fa3'/>
<id>urn:sha1:1f7ce4316d8c8ca8fdf5e477fee91012420b1fa3</id>
<content type='text'>
When the kmsg_dumper callback parameter changed, the reason variable
in mtdoops_do_dump() was not updated accordingly.
This breaks the build with mtdoops.

Fixes: e1a261ba599e ("printk: Add a short description string to kmsg_dump()")
Suggested-by: Knop Ryszard &lt;ryszard.knop@intel.com&gt;
Signed-off-by: Jocelyn Falempe &lt;jfalempe@redhat.com&gt;
Acked-by: Richard Weinberger &lt;richard@nod.at&gt;
Link: https://patchwork.freedesktop.org/patch/msgid/20240719152542.1554440-1-jfalempe@redhat.com
</content>
</entry>
<entry>
<title>printk: Add a short description string to kmsg_dump()</title>
<updated>2024-07-17T10:35:24+00:00</updated>
<author>
<name>Jocelyn Falempe</name>
<email>jfalempe@redhat.com</email>
</author>
<published>2024-07-02T12:26:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.landau.one/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=e1a261ba599eec97e1c5c7760d5c3698fc24e6a6'/>
<id>urn:sha1:e1a261ba599eec97e1c5c7760d5c3698fc24e6a6</id>
<content type='text'>
kmsg_dump doesn't forward the panic reason string to the kmsg_dumper
callback.
This patch adds a new struct kmsg_dump_detail, that will hold the
reason and description, and pass it to the dump() callback.

To avoid updating all kmsg_dump() call, it adds a kmsg_dump_desc()
function and a macro for backward compatibility.

I've written this for drm_panic, but it can be useful for other
kmsg_dumper.
It allows to see the panic reason, like "sysrq triggered crash"
or "VFS: Unable to mount root fs on xxxx" on the drm panic screen.

v2:
 * Use a struct kmsg_dump_detail to hold the reason and description
   pointer, for more flexibility if we want to add other parameters.
   (Kees Cook)
 * Fix powerpc/nvram_64 build, as I didn't update the forward
   declaration of oops_to_nvram()

Signed-off-by: Jocelyn Falempe &lt;jfalempe@redhat.com&gt;
Acked-by: Petr Mladek &lt;pmladek@suse.com&gt;
Acked-by: Michael Ellerman &lt;mpe@ellerman.id.au&gt; (powerpc)
Acked-by: Kees Cook &lt;kees@kernel.org&gt;
Link: https://patchwork.freedesktop.org/patch/msgid/20240702122639.248110-1-jfalempe@redhat.com
</content>
</entry>
<entry>
<title>mtd: mtdoops: panic caused mtdoops to call mtdoops_erase function immediately</title>
<updated>2022-11-07T16:08:00+00:00</updated>
<author>
<name>Ray Zhang</name>
<email>sgzhang@google.com</email>
</author>
<published>2022-10-10T04:55:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.landau.one/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=7cc84e0e07d063c246809ea78f51607f858766bf'/>
<id>urn:sha1:7cc84e0e07d063c246809ea78f51607f858766bf</id>
<content type='text'>
The panic function disables the local interrupts, preemption, and all
other processors. When the invoked mtdoops needs to erase a used page,
calling schedule_work() to do it will not work. Instead, just call
mtdoops_erase function immediately.

Tested:
~# echo c &gt; /proc/sysrq-trigger
[  171.654759] sysrq: Trigger a crash
[  171.658325] Kernel panic - not syncing: sysrq triggered crash
......
[  172.406423] mtdoops: not ready 34, 35 (erase immediately)
[  172.432285] mtdoops: ready 34, 35
[  172.435633] Rebooting in 10 seconds..

Signed-off-by: Ray Zhang &lt;sgzhang@google.com&gt;
Signed-off-by: Miquel Raynal &lt;miquel.raynal@bootlin.com&gt;
Link: https://lore.kernel.org/linux-mtd/20221010045549.2221965-4-sgzhang@google.com
</content>
</entry>
<entry>
<title>mtd: mtdoops: add mtdoops_erase function and move mtdoops_inc_counter to after it</title>
<updated>2022-11-07T16:07:59+00:00</updated>
<author>
<name>Ray Zhang</name>
<email>sgzhang@google.com</email>
</author>
<published>2022-10-10T04:55:48+00:00</published>
<link rel='alternate' type='text/html' href='https://git.landau.one/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=340193e079a899f5527cddccff2b5de2c98bc31b'/>
<id>urn:sha1:340193e079a899f5527cddccff2b5de2c98bc31b</id>
<content type='text'>
Preparing for next patch with minimal code difference, add mtdoops_erase
function and move mtdoops_inc_counter to after it, with no functional
change.

Signed-off-by: Ray Zhang &lt;sgzhang@google.com&gt;
Signed-off-by: Miquel Raynal &lt;miquel.raynal@bootlin.com&gt;
Link: https://lore.kernel.org/linux-mtd/20221010045549.2221965-3-sgzhang@google.com
</content>
</entry>
<entry>
<title>mtd: mtdoops: change printk() to counterpart pr_ functions</title>
<updated>2022-11-07T16:07:59+00:00</updated>
<author>
<name>Ray Zhang</name>
<email>sgzhang@google.com</email>
</author>
<published>2022-10-10T04:55:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.landau.one/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=43cfba56d312f0a45e0b3eaa63606e05ae7fac14'/>
<id>urn:sha1:43cfba56d312f0a45e0b3eaa63606e05ae7fac14</id>
<content type='text'>
To comply with latest kernel code requirement, change printk() to
counterpart pr_ functions in mtdoops driver:
- change printk(INFO) to pr_info()
- change printk(DEBUG) to pr_debug()
- change printk(WARNING) to pr_warn()
- change printk(ERR) to pr_err()

Note that only if dynamic debugging is enabled or DEBUG is defined,
printk(KERN_DEBUG) and pr_debug() are equivalent; Otherwise pr_debug()
is no-op, causing different behavior.

Signed-off-by: Ray Zhang &lt;sgzhang@google.com&gt;
Signed-off-by: Miquel Raynal &lt;miquel.raynal@bootlin.com&gt;
Link: https://lore.kernel.org/linux-mtd/20221010045549.2221965-2-sgzhang@google.com
</content>
</entry>
<entry>
<title>mtd: mtdoops: Add a timestamp to the mtdoops header.</title>
<updated>2022-04-26T07:27:12+00:00</updated>
<author>
<name>Jean-Marc Eurin</name>
<email>jmeurin@google.com</email>
</author>
<published>2022-04-25T16:09:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.landau.one/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=aa641a22bb5b1971a459b37746b845e3f5f084ca'/>
<id>urn:sha1:aa641a22bb5b1971a459b37746b845e3f5f084ca</id>
<content type='text'>
On some systems, the oops only has relative time from boot.

Signed-off-by: Jean-Marc Eurin &lt;jmeurin@google.com&gt;
Signed-off-by: Miquel Raynal &lt;miquel.raynal@bootlin.com&gt;
Link: https://lore.kernel.org/linux-mtd/20220425160927.3823016-1-jmeurin@google.com
</content>
</entry>
<entry>
<title>mtd: mtdoops: Create a header structure for the saved mtdoops.</title>
<updated>2022-04-26T07:27:07+00:00</updated>
<author>
<name>Jean-Marc Eurin</name>
<email>jmeurin@google.com</email>
</author>
<published>2022-04-21T23:42:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.landau.one/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=0bd359ee712d9d3e757971ded4094c8ba006acd4'/>
<id>urn:sha1:0bd359ee712d9d3e757971ded4094c8ba006acd4</id>
<content type='text'>
Create a dump header to enable the addition of fields without having
to modify the rest of the code.

Reported-by: kernel test robot &lt;lkp@intel.com&gt;
Signed-off-by: Jean-Marc Eurin &lt;jmeurin@google.com&gt;
Signed-off-by: Miquel Raynal &lt;miquel.raynal@bootlin.com&gt;
Link: https://lore.kernel.org/linux-mtd/20220421234244.2172003-3-jmeurin@google.com
</content>
</entry>
</feed>
