From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03A69C7618F for ; Mon, 15 Jul 2019 14:40:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C201C205ED for ; Mon, 15 Jul 2019 14:40:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563201641; bh=xDIQ42ChWf87NqLYQmiqW9h30yxZvey0pdV86at6Hx4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=FBIfS+JraFTdSY+lxJOb7jXTOY5A1o3oddJBuWTloPXHTFnBFpq7oG51eIJJ+jr5C QrV4jtwJwo1WWu0vuFAaaiahwZjA10MNPtGOg0oUfIMv3qAs8JK8jdahwqVb/hS7gR QVEIJkvc2S5ZYeoE1gRHLIR3CwhTcX0hyPQLosq4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404490AbfGOOkj (ORCPT ); Mon, 15 Jul 2019 10:40:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:42090 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404476AbfGOOkf (ORCPT ); Mon, 15 Jul 2019 10:40:35 -0400 Received: from sasha-vm.mshome.net (unknown [73.61.17.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9F75A205ED; Mon, 15 Jul 2019 14:40:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563201634; bh=xDIQ42ChWf87NqLYQmiqW9h30yxZvey0pdV86at6Hx4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A0fWQKMp+GX0sNa2TkpKCwIfkK/r04++bI5fo3QGpAvRc7Dtg79TGjNRdfSBIz/sz m5tx2VhbhoyRMIZb9XSeBRt6Fqvq1dMkD1puzScP2SlysRzwqRn9ObdkF4LszpFbQQ Hh8zG8HHDidU/nbENXZ9/n6bm+kAWYRJuneBirZY= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Ferdinand Blomqvist , Thomas Gleixner , Sasha Levin Subject: [PATCH AUTOSEL 4.9 59/73] rslib: Fix handling of of caller provided syndrome Date: Mon, 15 Jul 2019 10:36:15 -0400 Message-Id: <20190715143629.10893-59-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190715143629.10893-1-sashal@kernel.org> References: <20190715143629.10893-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ferdinand Blomqvist [ Upstream commit ef4d6a8556b637ad27c8c2a2cff1dda3da38e9a9 ] Check if the syndrome provided by the caller is zero, and act accordingly. Signed-off-by: Ferdinand Blomqvist Signed-off-by: Thomas Gleixner Link: https://lkml.kernel.org/r/20190620141039.9874-6-ferdinand.blomqvist@gmail.com Signed-off-by: Sasha Levin --- lib/reed_solomon/decode_rs.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/reed_solomon/decode_rs.c b/lib/reed_solomon/decode_rs.c index 8eed0f9ac495..a5d313381539 100644 --- a/lib/reed_solomon/decode_rs.c +++ b/lib/reed_solomon/decode_rs.c @@ -42,8 +42,18 @@ BUG_ON(pad < 0 || pad >= nn); /* Does the caller provide the syndrome ? */ - if (s != NULL) - goto decode; + if (s != NULL) { + for (i = 0; i < nroots; i++) { + /* The syndrome is in index form, + * so nn represents zero + */ + if (s[i] != nn) + goto decode; + } + + /* syndrome is zero, no errors to correct */ + return 0; + } /* form the syndromes; i.e., evaluate data(x) at roots of * g(x) */ -- 2.20.1