Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp781506ybd; Wed, 26 Jun 2019 06:05:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqw7VC2d2syKUsaMmEFaiXDcapwODTziTyxLmO1U+t7QL8Y0JFBNA6+jUWWZlLYrOBJCmWMF X-Received: by 2002:a17:902:da4:: with SMTP id 33mr4916175plv.209.1561554341296; Wed, 26 Jun 2019 06:05:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561554341; cv=none; d=google.com; s=arc-20160816; b=xZanQga4CtQHAhu5cyIqOMyO6Pv1kf/ezBlJp7d1I7evyJ2COm+Y1heYxENIKkSsgu Jxo/dTQkV7RFymRHcYZYf4R0yJjQYmI0ZMGkP4fEJZLgZqwwZVfhuXZLYMANmj7OBk+q IzQfQWjFLbxLGucQGC/IvAg+bHsoL45i6ydpkYA5QrGVVJPgmYfrsp2YLNmvz2/86vq9 01r5oLJ3o2Ex87zbdenmkwQvJ8lakrflDRK8KAKl/x3YKlleZLOxl3geWg7AqwNjdgx0 7nmc04ZiZajX3YEpRMNjxE2Wpdw8DXPrvdQlxEzeavCaHS5KFBKGRgtGEoBv2cUpkkka emfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:dkim-signature:dkim-filter; bh=KtxY5Wka3hwoP3Ovfl3Ckf4YVnAZn5qUfm69TgUEqPo=; b=nN16iGhHOnKiP6Lp18vl0u5JGEgS1xbQlpGFDafkoEPfpf2/N87iu7GYqoQsi3Yi5m wgLEv1Gh0Xuj+sjbKHxFIs+MrRN1fqR5L6rofEy4+SwjA/67Es40uUV+u59PZnCJ0PoY 4USMABUZoi4EigF2/wvQcinCb/KLBg8ysNURzWIEP2gT7j14rhvHbXircrWjwgZ+926R n54AdYtP//IHiu3Xs6PbvQjghUd7wmjkbl1wA/xIkbpv861zOmeT59KH+yI4gGkb2kJr iHBb5aR2BvA1UzzxT1KQ9JJnQEco8mtf1JFihTU9sHigAohOfPQKwcrzCgg7VdRe3PAm ublw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zytor.com header.s=2019061801 header.b=vMI4r8pk; 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=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d5si15748713pgv.584.2019.06.26.06.05.24; Wed, 26 Jun 2019 06:05:41 -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; dkim=pass header.i=@zytor.com header.s=2019061801 header.b=vMI4r8pk; 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=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727353AbfFZNEP (ORCPT + 99 others); Wed, 26 Jun 2019 09:04:15 -0400 Received: from terminus.zytor.com ([198.137.202.136]:47389 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726131AbfFZNEP (ORCPT ); Wed, 26 Jun 2019 09:04:15 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x5QD49si4114606 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 26 Jun 2019 06:04:09 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 terminus.zytor.com x5QD49si4114606 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2019061801; t=1561554249; bh=KtxY5Wka3hwoP3Ovfl3Ckf4YVnAZn5qUfm69TgUEqPo=; h=Date:From:Cc:Reply-To:In-Reply-To:References:To:Subject:From; b=vMI4r8pk/yB2/V1BNPuMsfAUjM3CguuSTnMl63KOD8Y1xLtVgO/Ihl5qT1WBvVSQH avF+nnZbTrlLGlw/exdDd49Yruw48Y0QebVqB+cd6FbwlzFeWQidfFEMaxEXOiLq9k cKJlND323KumSNbrA5KJC5CHbkVtaHJQ9R4joFFsnV9TaTvR1/e2wr2mSvHrnjScN0 bSBYX5kK/NwEDTPgCrQhqdBWOkj/S71jUyMOx8wg8fhsR8epOUe+d0rgXuItQi6/lF E1J2MyeP8U/hVnL/T0LMUOk7F+L5vDMtLs5ne13QAreli2IPoorWGAZPz7FAyfPlwe ANpJC0eqYb89g== Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x5QD49f14114603; Wed, 26 Jun 2019 06:04:09 -0700 Date: Wed, 26 Jun 2019 06:04:09 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Ferdinand Blomqvist Message-ID: Cc: tglx@linutronix.de, linux-kernel@vger.kernel.org, hpa@zytor.com, ferdinand.blomqvist@gmail.com, mingo@kernel.org Reply-To: mingo@kernel.org, linux-kernel@vger.kernel.org, ferdinand.blomqvist@gmail.com, hpa@zytor.com, tglx@linutronix.de In-Reply-To: <20190620141039.9874-6-ferdinand.blomqvist@gmail.com> References: <20190620141039.9874-6-ferdinand.blomqvist@gmail.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:core/rslib] rslib: Fix handling of of caller provided syndrome Git-Commit-ID: ef4d6a8556b637ad27c8c2a2cff1dda3da38e9a9 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=2.2 required=5.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_FUTURE_12_24,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU, DKIM_VALID_EF,FREEMAIL_FORGED_REPLYTO autolearn=no autolearn_force=no version=3.4.2 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: ef4d6a8556b637ad27c8c2a2cff1dda3da38e9a9 Gitweb: https://git.kernel.org/tip/ef4d6a8556b637ad27c8c2a2cff1dda3da38e9a9 Author: Ferdinand Blomqvist AuthorDate: Thu, 20 Jun 2019 17:10:37 +0300 Committer: Thomas Gleixner CommitDate: Wed, 26 Jun 2019 14:55:47 +0200 rslib: Fix handling of of caller provided syndrome 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 --- 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 78629bbe6590..b7264a712d46 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 - nroots); /* 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) */