Page MenuHomeFreeBSD

ufshci: tolerate partially constructed queues in SDB teardown
ClosedPublic

Authored by jaeyoon on Aug 5 2026, 8:03 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Sep 23, 2:24 PM
Unknown Object (File)
Mon, Sep 21, 12:32 AM
Unknown Object (File)
Sun, Sep 20, 7:44 AM
Unknown Object (File)
Sat, Sep 19, 10:21 PM
Unknown Object (File)
Fri, Sep 11, 8:59 PM
Unknown Object (File)
Wed, Sep 9, 1:05 AM
Unknown Object (File)
Tue, Sep 8, 11:20 PM
Unknown Object (File)
Tue, Sep 8, 4:17 AM
Subscribers
None

Details

Summary

When attach fails, ufshci_req_sdb_destroy() runs on a partially
constructed queue, and it runs twice: once from the construct error
path and once from the controller destructor.

Make that safe: NULL-check each resource before freeing it and clear
the pointer afterwards, so a second call finds nothing to do. The
construct error label no longer frees the command descriptors itself,
which fixes a double free of ucd_bus_addr. Also destroy the payload
DMA tag, which was previously leaked. Drop the mtx_initialized()
checks: the locks are always set up before any failure path can reach
the destroy.

Attach can also fail before the queues were constructed at all. The
destructor would then call a NULL qops.destroy pointer, so skip the
destroy when the queue was never set up.

Sponsored by: Samsung Electronics

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable