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,USER_AGENT_GIT autolearn=ham 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 4EC9AC7618F for ; Mon, 15 Jul 2019 14:55:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1DADE2067C for ; Mon, 15 Jul 2019 14:55:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563202541; bh=9oPmWzZADG9KBbFCDoRtLvhV03Hq67ZJeep/W6VUocU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=cYQRpTGS2UlW9MuJWGE6XZERQfYfv1aY/X2m56UXet9npcnHhcUMt5q2gu0NhObnj oC+EufKhRix4Ejg2Vj4FtCoLqKHXorMgcRmhwchjw1vRuUbVC/M+Ipbvp0rSuge75F xV21Dt8krbUit5laUcfafnABZu3sekYkk0oALs4E= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390677AbfGOOZZ (ORCPT ); Mon, 15 Jul 2019 10:25:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:60256 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389685AbfGOOZQ (ORCPT ); Mon, 15 Jul 2019 10:25:16 -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 869F020896; Mon, 15 Jul 2019 14:25:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563200716; bh=9oPmWzZADG9KBbFCDoRtLvhV03Hq67ZJeep/W6VUocU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V74mhfoxCGbr6aygqxmDJg0WL2OOcsOLymudRLavZyESACLsJ3ybv/cZQ964BqVYU J97wSeX8eiqXnkf3i/8JEPrXkpt3MW2jMhw1guGScahnh0mIyQQ474fLxZD6k2cFHu MbI2mg/CkuVo/aUioK+nxtm/UZ5VQDhOmSIz1DOg= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Ferdinand Blomqvist , Thomas Gleixner , Sasha Levin Subject: [PATCH AUTOSEL 4.19 116/158] rslib: Fix handling of of caller provided syndrome Date: Mon, 15 Jul 2019 10:17:27 -0400 Message-Id: <20190715141809.8445-116-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190715141809.8445-1-sashal@kernel.org> References: <20190715141809.8445-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 3313bf944ff1..121beb2f0930 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