Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9984192ybi; Wed, 24 Jul 2019 13:32:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqwk4a1UBV84SNM7MKN0Cx6xgHiaFQsXMXugUFzQy5h5UI4ilkyMWvAnq2GiADQlUCMfcUwG X-Received: by 2002:a65:5043:: with SMTP id k3mr25251213pgo.406.1564000357991; Wed, 24 Jul 2019 13:32:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564000357; cv=none; d=google.com; s=arc-20160816; b=o7/LYi43R3lK9flDDRYpmg74MyA+ZmYUEBoCtDR6EZqpUu3dpPHPk5pE9REaK0VbPx nlJmr4VrewXdDhlhFW+B6AZgLicB1K5pXErJ6HH3tngXe0CZn88IIASkg8kaas+Yq7tU NdwZDJ3eJXnleNitdb5UStSSffDfY/q9h90aSCYsYPTIM3XvGG7PQNvnibdYkV9JwzMo fERFZ/cudZzt3LAgas4XzzO784OY0Behmvs+Ahf+SGYABY5zjFRtUsEuCji98BPHg22j fmVq6GZvui4itoaH9irt7v8B7eedWAksc+nhjc9ZKpYsQ6eR4y+RvOqZdrhZjxpU6sxY SDhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Sn9zBoom42k+hW52GX7LiA5eNKzTywMAVuCxGeDfLQI=; b=ERbvXAl/8vUPaUD4jknoZcobiJwCzDMme/eTA1kW11emK5bvx+YLmUc3sW2sEqM3uI rOEyXFmDLxHAzD+kC0mCkdD7KKtZCX5+zU+u9+zswXSohrJtd2u5ItI0jdksv4HZTyWG GMgxm9O6ubfLJjt5TrpRxj8X9tBLxigmyDQh5DZMqe+XiJCr09imPt9ZU3z5hk4ubTdE kwK0pD50FCS0yH8Pf1zIpTSflbF6/g4F9bEgz69VHlgcox8O2KG8aBkXch3wrlbJd8yZ A50pCIw9kh+0Begb//o2zBNAd3mPgMGIOT30ToAtJyAI2OMeC5vyaB1Tj52uSyryAb4o JT6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MT1x5qNM; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h10si16057582pfk.197.2019.07.24.13.32.23; Wed, 24 Jul 2019 13:32:37 -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=@kernel.org header.s=default header.b=MT1x5qNM; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729147AbfGXTbG (ORCPT + 99 others); Wed, 24 Jul 2019 15:31:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:51610 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729004AbfGXTbE (ORCPT ); Wed, 24 Jul 2019 15:31:04 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 585882238C; Wed, 24 Jul 2019 19:31:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563996663; bh=cosIYsLoDbojTikTTllFASYBvS4Q4wiXY0nvkkX8xGk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MT1x5qNM1O5c1xbEOIwW3cHT72DSBmV7PTuuptR5pM3jcLzXH6HYn8WL97lZUp6Ld HfdTEAM/k8k1BW/22sTAmKnRA2xB/Oulut7akD2WU9usKjEEMX+yIhaxAx+IEJ8Rqb sa4RXi5YIGxB7jk3bizICDUoQkbfaOY0mzy8oYF0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ferdinand Blomqvist , Thomas Gleixner , Sasha Levin Subject: [PATCH 5.2 175/413] rslib: Fix handling of of caller provided syndrome Date: Wed, 24 Jul 2019 21:17:46 +0200 Message-Id: <20190724191747.423104356@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191735.096702571@linuxfoundation.org> References: <20190724191735.096702571@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ 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