Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4333275imm; Tue, 11 Sep 2018 10:15:16 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYJiGFhKY+CvIDZSIyhwm31hFivGlJwXDW1sv8wqCENwoO/RiC88dCcKQmHCiL+XWzOYYPZ X-Received: by 2002:a63:4826:: with SMTP id v38-v6mr29686812pga.379.1536686116579; Tue, 11 Sep 2018 10:15:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536686116; cv=none; d=google.com; s=arc-20160816; b=CqfYUfMbwhTBcINHh66EcyxDeSvDASzee/ZLctgV8HW6phetXzo2qHXH6I9DPeCNFt 9dg4jK9+2EDGm+EOr6H/WYoTeS+nwIpOY7nmJnCiXSymWefqU8W3F70pxL5ak2TBUPaO XY7vzTZUTm7n4TF5yYUMPoO51iAGlNFkSLPTKEsc1n9biZxX/x/qRpsZmjk6j4COb5d/ 3NrrW1cuAh6UhpU0/iNf/t8v+I80p6YGa+M0eCZlakMvkzmRS/ehig6OtcuPYv2B75CQ p2J6WqQFdvujP8Q+WxVKmiyNrTOshrclKt7x+U7yJJFVTmadFiPXRtPckjI+drpywI7f 32EQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=MQZbXVy2iALthGmlJpl30xRVVfFmhqCkH/u06zoU3VQ=; b=gC90zVoU0TUy+70tsUFHy+i5Zle8fNAnftXVfaeMqN5PrCLs/Y61+AVTLYl1s76D6c kmpvogf4hDiZ7dba7QrlWRpOC7KiZ2gPkrce94oYCxLvLOPubqtmHeW2JUGLKPock/42 VeVWTRFmVHgdQQ7FXyo2Dyr7S5zyPAkRAG0hDglM9IETrAe3qFUNasqOr5xV0TuPsmpg TBWkNXdlfWD9oGUPBx39XXjyineMPB0NKKzRD0qLtB/3hxm7kXv21Povieq/Z6QK9OY5 86xMrVVLZGE9pGL5CgVrXqaJ8c628i6iE/KWv+929FxeEPAnUPrY+3oxCSmMIvDqZ5eJ oEKw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o21-v6si20669901pgl.165.2018.09.11.10.14.54; Tue, 11 Sep 2018 10:15:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728149AbeIKWOw (ORCPT + 99 others); Tue, 11 Sep 2018 18:14:52 -0400 Received: from mga09.intel.com ([134.134.136.24]:19786 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726943AbeIKWOw (ORCPT ); Tue, 11 Sep 2018 18:14:52 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Sep 2018 10:14:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,361,1531810800"; d="scan'208";a="262579603" Received: from chenyu-desktop.sh.intel.com ([10.239.160.116]) by fmsmga006.fm.intel.com with ESMTP; 11 Sep 2018 10:14:32 -0700 From: Chen Yu To: Thomas Gleixner , "Rafael J. Wysocki" Cc: Pavel Machek , Rui Zhang , Chen Yu , Zhimin Gu , Len Brown , linux-kernel@vger.kernel.org, x86@kernel.org, linux-pm@vger.kernel.org, Chen Yu Subject: [PATCH 2/4][v2] PM / hibernate: Check the success of generating md5 digest before hibernation Date: Wed, 12 Sep 2018 01:20:36 +0800 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently if get_e820_md5() fails, then it will hibernate nevertheless. Actually the error code should be propagated to upper caller so that the hibernation could be aware of the result and terminates the process if md5 digest fails. Suggested-by: Thomas Gleixner Cc: "Rafael J. Wysocki" Signed-off-by: Chen Yu --- arch/x86/power/hibernate_64.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/arch/x86/power/hibernate_64.c b/arch/x86/power/hibernate_64.c index f8e3b668d20b..dc12dc57889e 100644 --- a/arch/x86/power/hibernate_64.c +++ b/arch/x86/power/hibernate_64.c @@ -265,9 +265,9 @@ static int get_e820_md5(struct e820_table *table, void *buf) return ret; } -static void hibernation_e820_save(void *buf) +static int hibernation_e820_save(void *buf) { - get_e820_md5(e820_table_firmware, buf); + return get_e820_md5(e820_table_firmware, buf); } static bool hibernation_e820_mismatch(void *buf) @@ -287,8 +287,9 @@ static bool hibernation_e820_mismatch(void *buf) return memcmp(result, buf, MD5_DIGEST_SIZE) ? true : false; } #else -static void hibernation_e820_save(void *buf) +static int hibernation_e820_save(void *buf) { + return 0; } static bool hibernation_e820_mismatch(void *buf) @@ -306,6 +307,7 @@ static bool hibernation_e820_mismatch(void *buf) int arch_hibernation_header_save(void *addr, unsigned int max_size) { struct restore_data_record *rdr = addr; + int ret = -EINVAL; if (max_size < sizeof(struct restore_data_record)) return -EOVERFLOW; @@ -333,7 +335,9 @@ int arch_hibernation_header_save(void *addr, unsigned int max_size) rdr->magic = RESTORE_MAGIC; - hibernation_e820_save(rdr->e820_digest); + ret = hibernation_e820_save(rdr->e820_digest); + if (ret) + return ret; return 0; } -- 2.17.1