Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1125904ybi; Fri, 2 Aug 2019 09:42:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqwosYKWppTP8LaSjsSYjXG7R7GAL92PbwP4vXNwxF2xmv2DTB8PKNbQ4c55j1lpAw3igbQW X-Received: by 2002:a17:90b:f0e:: with SMTP id br14mr5165571pjb.117.1564764134953; Fri, 02 Aug 2019 09:42:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564764134; cv=none; d=google.com; s=arc-20160816; b=vMdDgRKogQhCV/mFxqCrbmVpknwTgenKopqWsu0FHuW9JInf5RfeE2xj49iytYgcJz qthzcfC+PNaYUbH5Ndkbq+e7GAvwyTNWEjKZVQTsHtdC4nYC0VOlTBUr1qJ1xAXj3bdi xQuMb+3TDZ3x8P2qDqK8Ap3t+0wr4e+fO9b9Stb07PPNtSEM4TB+qmnuzE8Qru5kOSwI O6CtYTUkW6LZGWls54dh2CpGa9cRlMYO/jpUqdlTsWXMQ8k5gU2cjTSErGlWdWiKXU3A tA6lmMSkeEYKaP4XWFSPawxsw5SE/VJG31hbgU/vATyfR6hlKQHsZudG58TPzcwzVcG4 Jq1g== 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=x0CfNbdUyq+67/d7ShYKnfRxHNjZFBOH9yosQVuJBg4=; b=cU7082we3APM+RMSh4PjS65EplwxMatoRiJjSfRSLqtnQF15+XmnhldToD88HpNnnV dstCSgBogsTnDl2Of1Hp55HqYchQBjaYfkA8jrNS8JQ0BG8lTOgKFe6tIE5xCyGqAda4 WJb4IPa+cib5qyqtSYp9XnryO5UckgQ4y/khhVR/bv22B2aM50DcZc0948+55K/bg19m UoD2gXuI2JVtf5oTuoZGCW+BAmtHwHzOmHg9dw2ctIOBguM0JttrfnJjeksiCJ9ltePF dZZqEbcFlfnE87yH+dxjenPFInKYZE8S8y7OXtDA22dLp/O3wcXw4+i5QfI8LCsON+OA X+PQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GY4LMujY; 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 d4si36736257pgc.75.2019.08.02.09.41.59; Fri, 02 Aug 2019 09:42:14 -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=GY4LMujY; 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 S2391905AbfHBJmi (ORCPT + 99 others); Fri, 2 Aug 2019 05:42:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:44986 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391886AbfHBJme (ORCPT ); Fri, 2 Aug 2019 05:42:34 -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 8695420679; Fri, 2 Aug 2019 09:42:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564738954; bh=erNs80+xO89ji3FxGHqrr4RJNC78SHV0qgHFA/oqA5U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GY4LMujY1+2vJ0EEnrg2jn89pGz4F/Jl0oGDUjvrXW2FyCWV29fAorJBb2ocjdFCD A8tlMfeM1GYuzr0n+JYhRS9MRfA22rof8ph4tLNLauDTn/tbZF60K+lrca7GoOcS6w KfFuRUlbcZsHtAulBQolq8mFhFAd+m7MSt4njO04= 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 4.9 060/223] rslib: Fix handling of of caller provided syndrome Date: Fri, 2 Aug 2019 11:34:45 +0200 Message-Id: <20190802092242.745107649@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802092238.692035242@linuxfoundation.org> References: <20190802092238.692035242@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 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