Skip to content

Commit 3a62583

Browse files
RocheWilliamsuryasaimadhu
authored andcommitted
RAS/CEC: Correct ce_add_elem()'s returned values
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 <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Cc: <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent e49d033 commit 3a62583

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

drivers/ras/cec.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,11 +309,20 @@ static bool sanity_check(struct ce_array *ca)
309309
return ret;
310310
}
311311

312+
/**
313+
* cec_add_elem - Add an element to the CEC array.
314+
* @pfn: page frame number to insert
315+
*
316+
* Return values:
317+
* - <0: on error
318+
* - 0: on success
319+
* - >0: when the inserted pfn was offlined
320+
*/
312321
static int cec_add_elem(u64 pfn)
313322
{
314323
struct ce_array *ca = &ce_arr;
324+
int count, err, ret = 0;
315325
unsigned int to = 0;
316-
int count, ret = 0;
317326

318327
/*
319328
* 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)
330339
if (ca->n == MAX_ELEMS)
331340
WARN_ON(!del_lru_elem_unlocked(ca));
332341

333-
ret = find_elem(ca, pfn, &to);
334-
if (ret < 0) {
342+
err = find_elem(ca, pfn, &to);
343+
if (err < 0) {
335344
/*
336345
* Shift range [to-end] to make room for one more element.
337346
*/

0 commit comments

Comments
 (0)