Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3983165ybi; Mon, 29 Jul 2019 16:51:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqwrKNfBZCqup6WFXhtzzNVA1lg3pRS8htL4newaH7py0CMhyC2+tiAcqBeOubPnm5uRtEa8 X-Received: by 2002:a17:90a:23a4:: with SMTP id g33mr117659724pje.115.1564444295123; Mon, 29 Jul 2019 16:51:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564444295; cv=none; d=google.com; s=arc-20160816; b=enIN8M43tgREzg8saS1RnVIbCXlKVYikjrBqGwKNpQIe7mIDsLWOt+qWA30jpJ8NtU dkVoMvK9wGn3iuat9CBV4gT5iZgrRwqbHjt0yf/yDZGmgz3Il3J+HrVw14lQarUN1DQT Xd1jVbRKiaOQmtsS5SsB5fD6JAOO7b9ZnV39NAC+pZAuUWlRpDvHpL/afdSlJ92WgmkG Hy4jf5CCf6RRBLZiy9bW8WYI3FzHNk0aZMTWEVBNzrrPCWZv21JjZ3wutKZdkMyg5e7v fdwUIsOlHIOXZYsUDR0mrJ1UqITw9IIXP8x1CoTDOa87qjzzPIh0yz5dfwn3V8iNpTe5 FStA== 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=aJ6x5u8TmGlWtiQgFO7AmsWcx9tnWAcPoMbPzfUAkNPDz5Mm6VMCl/MoBv506ZYFqd nmti2nUEcIcgLI47MCU7jhcFjbuPQoxaVXIcqoXfzOjSYQgEcf95hbLvKtSUulg5I9Yj gqcjWEo/BveGUPmHndzVW4ObdEqjgedXc3vRhR8UUIVtKNpazb8JJepo4crDR3MtF7Fy DeQR0O0qv3utt/4gAzWmmdV2VXWY9kydOjM6RCRjnWeSi9zJ0zrCmJO8jCsSvtIWPA6R DcKDeR1kWiHqQmuA5uZSdF6dww5Byz+g56GKAI6pPEOlI8/MYjL82Z73gq9ov13VPrgr mx/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=e9UcqCgx; 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 e8si26366214plb.420.2019.07.29.16.51.20; Mon, 29 Jul 2019 16:51:35 -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=e9UcqCgx; 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 S1728531AbfG2T1m (ORCPT + 99 others); Mon, 29 Jul 2019 15:27:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:40286 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388361AbfG2T1k (ORCPT ); Mon, 29 Jul 2019 15:27:40 -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 779422070B; Mon, 29 Jul 2019 19:27:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564428460; bh=erNs80+xO89ji3FxGHqrr4RJNC78SHV0qgHFA/oqA5U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e9UcqCgxBLGqvhPf2oXugU+AkOPQbQdNFzPXKnDDm1+fjaU7wb4d3bSPvnKDvekQm 3PP4tvbczTbxy2ro+k1wXhcXteqw4gC9a5fIzftiXYSNe+O75RkeTSkkK/OM7P2vde gxJhqrz3Fd8zv3Xt28+X7YS2zL9MupBe3U0m49a4= 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.14 083/293] rslib: Fix handling of of caller provided syndrome Date: Mon, 29 Jul 2019 21:19:34 +0200 Message-Id: <20190729190830.981410509@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190820.321094988@linuxfoundation.org> References: <20190729190820.321094988@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