Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10409760ybi; Wed, 24 Jul 2019 22:42:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqy7aBLi9clh18GHooHlqhHIyC9XAlEqzvXrC0jy9QmN1UGjAQ/x/XX3HlNAXUJ4rRlhBK/s X-Received: by 2002:a17:902:2aa9:: with SMTP id j38mr85229511plb.206.1564033359802; Wed, 24 Jul 2019 22:42:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564033359; cv=none; d=google.com; s=arc-20160816; b=h/4UXg19KeVerBbkX+a/iel3OW2ZztWN5wdh/F0Scz573Hl6uxlJqb+OAwmEbFAj0+ f4Rle/C6irjz/tAUTJntjzqczPU1rQOyBkX0ezFNSEspSpgpDYWqh7GYIgL8o1tBQT8c gE64b0n1pRdSpcxDK9epEMzE2eJCcA8fIgK8kUSm/jdOO7GCyllZvy5LBqe32i/C2pvH 8li5N03hfjeKdaN1EFO1aWYLyZGah+jv7EprL0Vl/EOTpLvqXnWtugif3ivestcpghe4 QR+oPFOPe71WTLAF4XsU3kLwf3ngJd8vMTjEuGfppF+l//CyNkfrVTapC9E8qeSHenLB vuhw== 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=YiUflqaWLSZQpfkyfhN0Ms4hmTJyD/Ptej9nH9Cfi1ZBB+KirrTWIEVtP2SYy5jMDB o0Ga7ESfAfAVYdqOvrBNjJ+n8dVHZCpiQ3yOcCzf0SsFADTop2h5boJy93RfhbfuHGI+ QgXPQVgcUedYgM+oXren74mbiHmvgAfoYjqYQfNJTUt76IbZoTA6FwGolyECPGA20Yml EQiytWnb7XhFjz/TIPBPTnaW5L5/9/7KcfKluYyVzhr8mQYjgvjBd9JQCgYizdTux8V9 70qdcAJGOg0aCnqr8LTrmXq8wxTLsaB2lLU5ylY/Kp0J8LT+sAcnllW0ag/TBWJlJlg3 kH4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=m8UAJwS2; 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 q187si15547578pfb.51.2019.07.24.22.42.25; Wed, 24 Jul 2019 22:42:39 -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=m8UAJwS2; 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 S2392863AbfGXURE (ORCPT + 99 others); Wed, 24 Jul 2019 16:17:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:59480 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403863AbfGXTuj (ORCPT ); Wed, 24 Jul 2019 15:50:39 -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 69C8D217D4; Wed, 24 Jul 2019 19:50:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563997838; bh=cosIYsLoDbojTikTTllFASYBvS4Q4wiXY0nvkkX8xGk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m8UAJwS2+vjVR2e3sGGoer377bceZSf/bsEhFu7pj+L6c/72hZyniNEH0zavvPgou LQ4W/26Ro1ozqTxiEOdJuKdPp7iAQwlE+2VQZbl6mAXZ+fxxOuoMtWAb/2sNR1yUwA WAd/FhIJLIwRZKzD2H/wsWoGmhqvnqX05lPmArj0= 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.1 159/371] rslib: Fix handling of of caller provided syndrome Date: Wed, 24 Jul 2019 21:18:31 +0200 Message-Id: <20190724191737.128277013@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191724.382593077@linuxfoundation.org> References: <20190724191724.382593077@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