Skip to content

Commit 8aa9807

Browse files
committed
Tidy up the patches.
1 parent 1d6dfe3 commit 8aa9807

File tree

5 files changed

+30
-590
lines changed

5 files changed

+30
-590
lines changed

patches/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Overview of the implemented patches
2+
3+
This document outlines the purpose and background for each of the patches in the current folder.
4+
5+
1) `cs_error_handling.patch`
6+
* Purpose: Fix handling of the invalid inputs in the Channel Sounding (cs) module.
7+
* During the unit testing of the aforementioned module, a couple of errors were uncovered due to invalid input handling (e.g. not checking the NULL values).
8+
* This patch adds inputs and return values checks in order to avoid errors.
9+
10+
2) `userchan_fix_uninit_access.patch`
11+
* Purpose: Fix the usage of memory errors reported by Valgrind memcheck.
12+
* During the `bind()` system call in `userchan.c`, Valgrind detected the uninitialized bytes usage. The problem here was that the `sockaddr_hci` struct (that was in use) and `sockaddr` struct (that `bind` expects) are not matching in size and layout, which caused the `bind` to access memory outside of the passed structure.
13+
* This patch adds the initialization of a bigger structure, `sockaddr`, fills in the relevant fields, and only then pass it to `bind`.
14+
15+
3) `nsi_cleanup.patch`
16+
* Purpose: Eliminate the false positive memory leaks reported by Valgrind on `nrf52_bsim` platform.
17+
* Valgrind used to report still reachable and possibly lost memory leaks within the `nsi_tasks.c`. The functions for freeing up the memory haven't been called due to the nature of simulated execution - `ON_EXIT` tasks are never executed because the program is running in an endless loop.
18+
* This patch adds `nsi_exit(0)` at the end of `main` in order to avoid the leakage. Additionally, the patch adds a maximal number of disconnects to the advertiser app that was tested.
19+
20+
4) Demo patches for demonstration of the Valgrind tool
21+
* This group of patches is not intended for bug fixing but serves to demonstrate Valgrind's capability to detect various types of memory errors.
22+
* `memleak_demo_initial.patch`: Introduces `mem_leak()` and `use_uninitialized_mem()` functions into the beacon sample to show basic memory error detection.
23+
* `memleak_demo_no_optimize.patch`: Adds `CONFIG_NO_OPTIMIZATIONS=y` to `prj.conf`. This prevents the compiler from removing the unused functions containing the intentional bugs, ensuring Valgrind can analyze them.
24+
* `memleak_demo_all_leaks.patch`: Expands the sample with functions that demonstrate all major memory leak categories (indirectly lost, possibly lost, still reachable).

0 commit comments

Comments
 (0)