git: 8ac6f5e39417 - stable/14 - kldxref: Appease a Coverity warning

From: John Baldwin <>
Date: Thu, 18 Jan 2024 22:26:01 UTC
The branch stable/14 has been updated by jhb:


commit 8ac6f5e3941796195ae1e78602523499a20b68b7
Author:     John Baldwin <>
AuthorDate: 2023-12-22 15:49:40 +0000
Commit:     John Baldwin <>
CommitDate: 2024-01-18 21:31:43 +0000

    kldxref: Appease a Coverity warning
    While parsing .dynamic, nsym is set when parsing the symbol table from
    .dynsym.  That parsing also sets ef->ef_symtab to a non-NULL value.
    The value of nsym isn't validated until after a check for
    ef->ef_symtab being NULL, so nsym always has a valid value when it is
    read.  However, that chain of events is a bit much for static analysis
    to follow, so initialize nsym to 0 before parsing sections to quiet
    the warning.
    Reported by:    Coverity Scan
    CID:            1532339
    Sponsored by:   DARPA
    (cherry picked from commit d281fece432f97b4424b852f23dfe1f974b9e30d)
 usr.sbin/kldxref/ef.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/usr.sbin/kldxref/ef.c b/usr.sbin/kldxref/ef.c
index 46d3dc1f4578..fd0782ff1dd0 100644
--- a/usr.sbin/kldxref/ef.c
+++ b/usr.sbin/kldxref/ef.c
@@ -361,6 +361,7 @@ ef_parse_dynamic(elf_file_t ef, const GElf_Phdr *phdyn)
 		goto out;
+	nsym = 0;
 	for (i = 0; i < nshdr; i++) {
 		switch (shdr[i].sh_type) {
 		case SHT_HASH: