Skip to content

Commit

Permalink
RAS/CEC: Correct ce_add_elem()'s returned values
Browse files Browse the repository at this point in the history
commit 3a62583 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: de0e062 ("RAS/CEC: Check count_threshold unconditionally")
Signed-off-by: William Roche <william.roche@oracle.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: <stable@vger.kernel.org>
Link: https://lkml.kernel.org/r/1617722939-29670-1-git-send-email-william.roche@oracle.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
RocheWilliam authored and gregkh committed Apr 14, 2021
1 parent 253acf2 commit 674ddb5
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions drivers/ras/cec.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,20 @@ static bool sanity_check(struct ce_array *ca)
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
Expand All @@ -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.
*/
Expand Down

0 comments on commit 674ddb5

Please sign in to comment.