]> git.baikalelectronics.ru Git - kernel.git/commit
PM / Hibernate: Do not crash kernel in free_basic_memory_bitmaps()
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 14 Nov 2013 22:26:58 +0000 (23:26 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 14 Nov 2013 22:26:58 +0000 (23:26 +0100)
commit55d0123c6d0a4b5b2dc36583888540b05870fb81
tree1c77c05c8d41003216262585a82155fcb448fa41
parentaeade29d0d840e61f6d1df36c6c5e1c9a1f4f43c
PM / Hibernate: Do not crash kernel in free_basic_memory_bitmaps()

I have received a report about the BUG_ON() in free_basic_memory_bitmaps()
triggering mysteriously during an aborted s2disk hibernation attempt.
The only way I can explain that is that /dev/snapshot was first
opened for writing (resume mode), then closed and then opened again
for reading and closed again without freezing tasks.  In that case
the first invocation of snapshot_open() would set the free_bitmaps
flag in snapshot_state, which is a static variable.  That flag
wouldn't be cleared later and the second invocation of snapshot_open()
would just leave it like that, so the subsequent snapshot_release()
would see data->frozen set and free_basic_memory_bitmaps() would be
called unnecessarily.

To prevent that from happening clear data->free_bitmaps in
snapshot_open() when the file is being opened for reading (hibernate
mode).

In addition to that, replace the BUG_ON() in free_basic_memory_bitmaps()
with a WARN_ON() as the kernel can continue just fine if the condition
checked by that macro occurs.

Fixes: 376a543f8d50 (PM / hibernate: Fix user space driven resume regression)
Reported-by: Oliver Lorenz <olli@olorenz.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: 3.12+ <stable@vger.kernel.org> # 3.12+
kernel/power/snapshot.c
kernel/power/user.c