Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2138526pxb; Mon, 12 Apr 2021 15:44:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwn5X+F7Zl8gXRER2KKbaJVXXCLsBe8/II41bKlI/qN/NYxuiLJqbTdtltmkYU+QoAj240I X-Received: by 2002:a17:90a:281:: with SMTP id w1mr1428240pja.201.1618267499401; Mon, 12 Apr 2021 15:44:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618267499; cv=none; d=google.com; s=arc-20160816; b=KTYNwuj6j13ZFmJahOYlMgggSi/gQFMD+Q5xkViGwOHhJkhOySGK/GWj3KPdJeEcNz u6aLJEyusihUwXCsEig0gVkn59Vq9/HzpKHym4Weww+zNcmzsXN6FP/8S8xXG+o3BIeE jnkjJj6WgePmLZNJQOAMbceiKDROLbbARCuSJZGlE1we+Bp/22yS1e3ostD9FRUGo2yC UTF2YqKXxkUlpPyBeHu62PsbHel0EtT7UwdOL6t95bqjVqT5+M4/ZbudwevGlZwTzfFV LE1FfRff4ZPmcBmr4CjEaZqKtQPaMhn+VvXBe2VRwIlvPREKnISYdyjO1MvOpmUN7lON +eJw== 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=w0sSjTEKUK8AiHAPP9OJR0OK7rbscgehTqpNzceIe1ApvYtMMqKS7lrFV3g8cHkMia pSnQyNKpHbyUyAM32kzapVdP5SJWeDC7vBAAmQ0EHCoGEKUiFAr9QLdr61XV6nhnF4NH OB4SHN3nKCkRtyXEwHGDfkpcATfsv+TDOvo4zdAChyo6Vwmx1XKeBZcGG3XDn7cS4DDE boNMi/YJ79H406emSM4vn33t97U0tucGr+PPL8dsAwbddLEaG37IjK/fVdkvtwn255kG DjWu89E8JByDTT287Rg0O5GpHH+V826UyTbIrMPaAPAIyXUk/t86oBrVlYc/pbQYugUE so7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bS0l8lRB; 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 f23si1690385plj.214.2021.04.12.15.44.47; Mon, 12 Apr 2021 15:44:59 -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=bS0l8lRB; 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 S241914AbhDLJjt (ORCPT + 99 others); Mon, 12 Apr 2021 05:39:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:35924 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240842AbhDLJLF (ORCPT ); Mon, 12 Apr 2021 05:11:05 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id EDB4A6137C; Mon, 12 Apr 2021 09:06:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618218417; bh=B6lBmkJc9AGNNM626ehx8HKi/VCxD74uQiqmG5rhVgI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bS0l8lRBGGMnPkJ7hoiBQLAYnYMMvg5Eb9lXvdC6Hs/t94ho7ZGCs9d7mRZzmc2gS 6tDeB5Kq7dr6Rc0WFIZmQ6ipVbDkCHb76egCcMKPX9B7asmfnpAT+Vp7qJMuPIYABh x3Nha2L5W5roZjXmbX6qDMmpJcB7LVF9i7+XFGn4= 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.11 190/210] RAS/CEC: Correct ce_add_elem()s returned values Date: Mon, 12 Apr 2021 10:41:35 +0200 Message-Id: <20210412084022.350715648@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210412084016.009884719@linuxfoundation.org> References: <20210412084016.009884719@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. */