Skip to content

Commit e785611

Browse files
authored
Fix SIGTERM segfault when rshim exits (#295)
When SIGTERM is sent to rshim process, a segfault could occur if rshim_backend_name is NULL. This happens when no specific backend is specified via command line (-b flag), which is the common auto-detect mode. This fix checks the actual backend types of registered devices instead of rshim_backend_name. Fixes: 6e4ed82 ("Deregister driver (vfio or uio) when not in use") RM #4654756
1 parent 3b3b004 commit e785611

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/rshim.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3059,9 +3059,12 @@ static void rshim_main(int argc, char *argv[])
30593059
}
30603060
}
30613061

3062-
if (!strcmp(rshim_backend_name, "pcie-lf") ||
3063-
!strcmp(rshim_backend_name, "pcie")) {
3064-
rshim_pcie_exit();
3062+
for (i = 0; i < RSHIM_MAX_DEV; i++) {
3063+
bd = rshim_devs[i];
3064+
if (bd && bd->type == RSH_BACKEND_PCIE) {
3065+
rshim_pcie_exit();
3066+
break;
3067+
}
30653068
}
30663069

30673070
rshim_stop();

0 commit comments

Comments
 (0)