From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-186.mta0.migadu.com (out-186.mta0.migadu.com [91.218.175.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5061E3E5EC0 for ; Fri, 8 May 2026 14:36:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.186 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778250973; cv=none; b=MQB0A0lXxg4FP2o7E75kKUERb2fbXno6oU8NcxBLtqsMFB3zGjy/qOO4NEzU7HGKzd8e3ryqnWjPhZcXi1KIY5snV8El21wCv9wWTvryY4MP9rpEYRj7dQOiPdKT3TD0zrvlkNJdCj7selrTATfAbmSPUGLGfjcdYNBFXwgzA/c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778250973; c=relaxed/simple; bh=zV4hfU38HPXgefG3ua5/+P1VbvLku9DJirIeEEEnM8s=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=CGckiYZhXKMGvHbYm2xIWxYOVm+ou4V63cvL4Ln7GGvcVvu13WBzihL+m99UmMFc/aHMaobho+XhOfdl91j4PmNk09EgM1AMbOk8iRrV9gaBGE54U5KaktnsW1+DKPlz+1sAuVe/05AiZRAmyzGx6i6r/u0dm38feWaHtb/5vrA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=Q+SzSz90; arc=none smtp.client-ip=91.218.175.186 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="Q+SzSz90" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1778250968; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=IvoGuPSpwla1RHAl1U8V7E6i8CVr6Fu/69QlhrzLoA4=; b=Q+SzSz903A0m+gJWvWamazwfoCVOWmwwVAWbRkiGsAYa/ffs3QLRykL4gHplrbTtatOQt9 3gTAw2MZe4JlZ7RP4BUBmANBTaZn8VwVH/xXf7j0vzqLk8sCvJRV+yKq6VyLj1J+p9Pr6M aG8rr9FQjzBmw9BS+0YtLtnfnCRmucA= From: Thorsten Blum To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Ard Biesheuvel , Eric Biggers Cc: Thorsten Blum , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH RESEND 1/2] riscv/purgatory: return bool from verify_sha256_digest Date: Fri, 8 May 2026 16:35:44 +0200 Message-ID: <20260508143544.2484-3-thorsten.blum@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1508; i=thorsten.blum@linux.dev; h=from:subject; bh=zV4hfU38HPXgefG3ua5/+P1VbvLku9DJirIeEEEnM8s=; b=owGbwMvMwCUWt7pQ4caZUj3G02pJDJl/vxw4c/Js6/aw+22bri/Tirohc/2dXWfKPrNpC65PX e93pqyVoaOUhUGMi0FWTJHlwawfM3xLayo3mUTshJnDygQyhIGLUwAm8oCX4Z/tVCmbNzyxBR7s v2af5T6/k/1W2E2GrByrI2brXW5JnDRmZFidu39Gw7Wbp5leTpdn7bjM9y/Kz/+KYEf1tfdMZ52 mpPABAA== X-Developer-Key: i=thorsten.blum@linux.dev; a=openpgp; fpr=1D60735E8AEF3BE473B69D84733678FD8DFEEAD4 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT Change the function's return type from int to bool and return the result of memcmp() directly to simplify the code. While at it, cast ->start to 'const u8 *' to better match the expected type. Signed-off-by: Thorsten Blum --- arch/riscv/purgatory/purgatory.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/arch/riscv/purgatory/purgatory.c b/arch/riscv/purgatory/purgatory.c index bbd5cfa4d741..15c72dafa3d8 100644 --- a/arch/riscv/purgatory/purgatory.c +++ b/arch/riscv/purgatory/purgatory.c @@ -17,7 +17,7 @@ u8 purgatory_sha256_digest[SHA256_DIGEST_SIZE] __section(".kexec-purgatory"); struct kexec_sha_region purgatory_sha_regions[KEXEC_SEGMENT_MAX] __section(".kexec-purgatory"); -static int verify_sha256_digest(void) +static bool verify_sha256_digest(void) { struct kexec_sha_region *ptr, *end; struct sha256_ctx sctx; @@ -26,11 +26,10 @@ static int verify_sha256_digest(void) sha256_init(&sctx); end = purgatory_sha_regions + ARRAY_SIZE(purgatory_sha_regions); for (ptr = purgatory_sha_regions; ptr < end; ptr++) - sha256_update(&sctx, (uint8_t *)(ptr->start), ptr->len); + sha256_update(&sctx, (const u8 *)(ptr->start), ptr->len); sha256_final(&sctx, digest); - if (memcmp(digest, purgatory_sha256_digest, sizeof(digest)) != 0) - return 1; - return 0; + + return memcmp(digest, purgatory_sha256_digest, sizeof(digest)); } /* workaround for a warning with -Wmissing-prototypes */