Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2108722pxb; Mon, 12 Apr 2021 14:47:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwr25CttqOFJ536PjhbS1qbLZP7fh6Z3AgFYlIaeVKMsF2MxkWZ3LcqX3qsQpevF/Tl8GiJ X-Received: by 2002:a17:902:6a87:b029:e6:6a3d:29e8 with SMTP id n7-20020a1709026a87b02900e66a3d29e8mr27654174plk.10.1618264031262; Mon, 12 Apr 2021 14:47:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618264031; cv=none; d=google.com; s=arc-20160816; b=dv/Y+gnTtvWx5zMy4K9jOpcW7xtYvi+M5sm3nD3CdnZZtrWY5cUHYmrGsFI2rz2ZAg zs5z7X3qekZw/SFjFuUNl2VqoVAb3wBrNw/6Oi87B94IEemzpF9Ig8w+4TTl7Rsqz2gp hJH/DlQ4kVNJIMMMCVBNLfhEMBiWfp2qJ8nf+eZbZnCgxsVdttlOJIucoCT3Z0pvDYyW eUVGJesQZKL+l8jjsZvRxCtLkUNgf6Hda+zI/ZUezPcPv2Rvgy+pRIyC0Ht7UNhWfWaE Icf8pUbPSxQb4JGz2X/6txS2nD8xxQGvnhql0kzXr92h7xU7YfoXUL0aglqVXz4rvocL /qWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=WISGlL/MQzZFkom2Z2mF5hNep1/dpsVt+AI0n6v1FDQ=; b=XQT8K1fSwZENUgzqtaga9RbpMKMHgDim0FWFcPttUkPXcix3K7YasfPyI4xheJvXYa Gvbm+HEYTAQuWDLivLdXNhaifefx85E25XcB0Bh5CUnEfprNlSVs+wRlSMRzJnIH/+A7 j9HEJ1cBvORR3rOiFGg4T8sQdzT3Z7Jl7jy4nv+HZfXAR2m2kaALSzosVDql/FAvMvVm blNgrujBIyAPDL2H0TzKubyd3X1oD+1JW4FsjkBmFJeTwastoFrpr+WhH2qYeBX2hJ+O Okqsuq0FafdQC7DKi44AzImXfiJ8MuCskYmFobE4I0EOWZhcpv6yBsQ4ruse3HwVUrx0 NH5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="pE/D8pwx"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v11si14048445plp.409.2021.04.12.14.46.49; Mon, 12 Apr 2021 14:47:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="pE/D8pwx"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241618AbhDLJQx (ORCPT + 99 others); Mon, 12 Apr 2021 05:16:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:49294 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239150AbhDLI7T (ORCPT ); Mon, 12 Apr 2021 04:59:19 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8DB0C6124C; Mon, 12 Apr 2021 08:57:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618217857; bh=B6lBmkJc9AGNNM626ehx8HKi/VCxD74uQiqmG5rhVgI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pE/D8pwxSUVj+tGtBQ/J6wJ2oxebkABBoiOcqXPOwHYTeu6Co0iJMRpDwcAbVvOSu STi+fM988PuJ0uLNikiigj5lQ3uks6JkfPGn+i9oLo8h1+aZ9ACFZvv67McvnVaxzz W2KOFvgSCn1sMQksfEz7zPSkq0rEfLcvHxwtp5K8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, William Roche , Borislav Petkov Subject: [PATCH 5.10 169/188] RAS/CEC: Correct ce_add_elem()s returned values Date: Mon, 12 Apr 2021 10:41:23 +0200 Message-Id: <20210412084019.250214213@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210412084013.643370347@linuxfoundation.org> References: <20210412084013.643370347@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: William Roche commit 3a62583c2853b0ab37a57dde79decea210b5fb89 upstream. ce_add_elem() uses different return values to signal a result from adding an element to the collector. Commit in Fixes: broke the case where the element being added is not found in the array. Correct that. [ bp: Rewrite commit message, add kernel-doc comments. ] Fixes: de0e0624d86f ("RAS/CEC: Check count_threshold unconditionally") Signed-off-by: William Roche Signed-off-by: Borislav Petkov Cc: Link: https://lkml.kernel.org/r/1617722939-29670-1-git-send-email-william.roche@oracle.com Signed-off-by: Greg Kroah-Hartman --- drivers/ras/cec.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) --- a/drivers/ras/cec.c +++ b/drivers/ras/cec.c @@ -309,11 +309,20 @@ static bool sanity_check(struct ce_array return ret; } +/** + * cec_add_elem - Add an element to the CEC array. + * @pfn: page frame number to insert + * + * Return values: + * - <0: on error + * - 0: on success + * - >0: when the inserted pfn was offlined + */ static int cec_add_elem(u64 pfn) { struct ce_array *ca = &ce_arr; + int count, err, ret = 0; unsigned int to = 0; - int count, ret = 0; /* * We can be called very early on the identify_cpu() path where we are @@ -330,8 +339,8 @@ static int cec_add_elem(u64 pfn) if (ca->n == MAX_ELEMS) WARN_ON(!del_lru_elem_unlocked(ca)); - ret = find_elem(ca, pfn, &to); - if (ret < 0) { + err = find_elem(ca, pfn, &to); + if (err < 0) { /* * Shift range [to-end] to make room for one more element. */