From 423c4f1994bebd8b106251e64ac1fcc04ba2df17 Mon Sep 17 00:00:00 2001 From: shisiyuan Date: Tue, 18 May 2021 11:47:43 +0800 Subject: [PATCH] KillZramBackingDevice: Return immediately if backing_dev is none. It's possible that CONFIG_ZRAM_WRITEBACK is y, but userspace doesn't set the /sys/block/zram0/backing_dev, so its value is 'none'. It's the same with "CONFIG_ZRAM_WRITEBACK is not set". Change-Id: I2df89ceee68e4685deef5113bada21be96779e9b Signed-off-by: shisiyuan --- init/reboot.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/init/reboot.cpp b/init/reboot.cpp index ab0e48e9e..0e788e495 100644 --- a/init/reboot.cpp +++ b/init/reboot.cpp @@ -478,6 +478,11 @@ static Result KillZramBackingDevice() { // cut the last "\n" backing_dev.erase(backing_dev.length() - 1); + if (android::base::StartsWith(backing_dev, "none")) { + LOG(INFO) << "No zram backing device configured"; + return {}; + } + // shutdown zram handle Timer swap_timer; LOG(INFO) << "swapoff() start...";