Coverage Report

Created: 2026-11-28 06:58

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/barebox/lib/list_debug.c
Line
Count
Source
1
/*
2
 * Copyright 2006, Red Hat, Inc., Dave Jones
3
 * Released under the General Public License (GPL).
4
 *
5
 * This file contains the linked list validation for DEBUG_LIST.
6
 */
7
8
#include <linux/export.h>
9
#include <linux/list.h>
10
#include <linux/bug.h>
11
#include <linux/kernel.h>
12
13
/*
14
 * Check that the data structures for the list manipulations are reasonably
15
 * valid. Failures here indicate memory corruption (and possibly an exploit
16
 * attempt).
17
 */
18
19
bool __list_add_valid_or_report(struct list_head *new, struct list_head *prev,
20
        struct list_head *next)
21
1.84M
{
22
1.84M
  if (CHECK_DATA_CORRUPTION(prev == NULL,
23
1.84M
      "list_add corruption. prev is NULL.\n") ||
24
1.84M
      CHECK_DATA_CORRUPTION(next == NULL,
25
1.84M
      "list_add corruption. next is NULL.\n") ||
26
1.84M
      CHECK_DATA_CORRUPTION(next->prev != prev,
27
1.84M
      "list_add corruption. next->prev should be prev (%px), but was %px. (next=%px).\n",
28
1.84M
      prev, next->prev, next) ||
29
1.84M
      CHECK_DATA_CORRUPTION(prev->next != next,
30
1.84M
      "list_add corruption. prev->next should be next (%px), but was %px. (prev=%px).\n",
31
1.84M
      next, prev->next, prev) ||
32
1.84M
      CHECK_DATA_CORRUPTION(new == prev || new == next,
33
1.84M
      "list_add double add: new=%px, prev=%px, next=%px.\n",
34
1.84M
      new, prev, next))
35
0
    return false;
36
37
1.84M
  return true;
38
1.84M
}
39
EXPORT_SYMBOL(__list_add_valid_or_report);
40
41
bool __list_del_entry_valid_or_report(struct list_head *entry)
42
1.81M
{
43
1.81M
  struct list_head *prev, *next;
44
45
1.81M
  prev = entry->prev;
46
1.81M
  next = entry->next;
47
48
1.81M
  if (CHECK_DATA_CORRUPTION(next == NULL,
49
1.81M
      "list_del corruption, %px->next is NULL\n", entry) ||
50
1.81M
      CHECK_DATA_CORRUPTION(prev == NULL,
51
1.81M
      "list_del corruption, %px->prev is NULL\n", entry) ||
52
1.81M
      CHECK_DATA_CORRUPTION(next == LIST_POISON1,
53
1.81M
      "list_del corruption, %px->next is LIST_POISON1 (%px)\n",
54
1.81M
      entry, LIST_POISON1) ||
55
1.81M
      CHECK_DATA_CORRUPTION(prev == LIST_POISON2,
56
1.81M
      "list_del corruption, %px->prev is LIST_POISON2 (%px)\n",
57
1.81M
      entry, LIST_POISON2) ||
58
1.81M
      CHECK_DATA_CORRUPTION(prev->next != entry,
59
1.81M
      "list_del corruption. prev->next should be %px, but was %px. (prev=%px)\n",
60
1.81M
      entry, prev->next, prev) ||
61
1.81M
      CHECK_DATA_CORRUPTION(next->prev != entry,
62
1.81M
      "list_del corruption. next->prev should be %px, but was %px. (next=%px)\n",
63
1.81M
      entry, next->prev, next))
64
0
    return false;
65
66
1.81M
  return true;
67
1.81M
}
68
EXPORT_SYMBOL(__list_del_entry_valid_or_report);