Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2066917pxb; Mon, 12 Apr 2021 13:27:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwjxO4tyfr206Gz2pAHVqcH7aGuNiXLHqrtLPg/gT2XP4IAEi8uizQlEA6HetDHgRp0j6hb X-Received: by 2002:a17:906:7d82:: with SMTP id v2mr29179557ejo.524.1618259262506; Mon, 12 Apr 2021 13:27:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618259262; cv=none; d=google.com; s=arc-20160816; b=euwxArrf++ojVvnl+L/5YdjnUeCUOVTx+Ks440spG98KCUjiAuo90LvKYyKW0y1Zya 9zN1JZxwVNZ64rcdyQqy5JHbfhIu6TGIT1Ow72QVzR/lYib3FHN7seN7okid4uyBrVEI qX1zTkD9vrnvEe/XNAhLwXbZU/XtZ+HYMS0VUnrgUH5js2y0x3+E+doeOlwpJiwny2TS 2DWbgfTRBtGEYTtKkzsu4RmdFJkhnwGkF+iI0O3T7VkhxTfzi7X4jsvmHSp+aEo/qHWs kk5p3myQrui8CLPr+DZv7fkWeJKblnCtTFDSOqMC9owp8yxcy9KhOXlNbScwaFx7r2rf Drcg== 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=BLC4Ei3R0TMvLMXOLNyX7Tokh9dAYxNx7UXAjbP4vQ0=; b=Bh3mE6VMwLSsEKtTc46errQO0XKSUgR0wL6NSrKhJl98Mni20PXhSULVRSisMEkOXF RpHF7Xj+ciFA9y/hwbPSavrP9Pnof7cMeAndZJ2R2yfH6DEqx9YW70OBiq30QzLR4Aly CO7zU400IMMZkDa79uf8nPnKlQYZJ+tElEQUHiag2kYxiJYvCGWvHjOX/jGmlDA6zMAV R2PNMDiU8KFDsHt870lJNcMs8vWDsZ8Yu+truGFlL/0tpjMLEQSLd//ARZV6bnQgrqku ewTM8phz+l5z8YxV8XPO2wl9Ha/djnbTCXq+1NAYuKmf6htWwEI5m5S4x7qNQ1oaZtOa 4dPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YKu7emLZ; 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 t23si8163033ejj.290.2021.04.12.13.27.18; Mon, 12 Apr 2021 13:27:42 -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=YKu7emLZ; 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 S238712AbhDLI6g (ORCPT + 99 others); Mon, 12 Apr 2021 04:58:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:40488 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238708AbhDLIu2 (ORCPT ); Mon, 12 Apr 2021 04:50:28 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DEEC8611F0; Mon, 12 Apr 2021 08:50:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618217411; bh=7khwu2IG/1lnTGfD54GNj/hWdGYeQlKlWGEELSEg1Nc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YKu7emLZspIJwwprmLjfaBGErmE50scgz7uGOzHCxBIDCog4wzA1Aj5A+QJwzuktj Ye6VoWbyyak6LMAA/9Kxh9lYH5LXSVpMuSa2fOaUWCunT6EkoNNHwGgjPOREH0Qt0K vWHiRFvvNtOxgXQjGQ+WwwCXPmYXZ+kZrE0x7Dho= 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.4 094/111] RAS/CEC: Correct ce_add_elem()s returned values Date: Mon, 12 Apr 2021 10:41:12 +0200 Message-Id: <20210412084007.383311692@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210412084004.200986670@linuxfoundation.org> References: <20210412084004.200986670@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 + */ 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 @@ 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. */