Skip to contentSkip to conversation

fabrics: fix NULL dereference in nvmf_update_tls_concat

PATCH Applied Stuart Hayes 2 participants 2 messages May 6 – May 7 NVMe

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fabrics: fix NULL dereference in nvmf_update_tls_concat

The recently added function nvmf_update_tls_concat() dereferences struct nvmf_disc_log_entry *e, but e will always be NULL when called via libnvmf_discovery_nbft(). This can result in a segmentation fault when attempting "nvme connect-all --nbft".

Check for NULL pointer before dereferencing.

---
 libnvme/src/nvme/fabrics.c | 3 +++
 1 file changed, 3 insertions(+)
libnvme/src/nvme/fabrics.c +3 -0
index 4572b9c5b..326287ec6 100644
@@ -1228,6 +1228,9 @@ __public int libnvmf_disconnect_ctrl(libnvme_ctrl_t c)
 static void nvmf_update_tls_concat(struct nvmf_disc_log_entry *e,
 		libnvme_ctrl_t c, libnvme_host_t h)
 {
+	if (!e)
+		return;
+
 	if (e->trtype != NVMF_TRTYPE_TCP ||
 	    e->tsas.tcp.sectype == NVMF_TCP_SECTYPE_NONE)
 		return;
Signature · 1 line
2.51.0
#1 lore raw
Quoted 8 lines · Stuart Hayes

The recently added function nvmf_update_tls_concat() dereferences struct nvmf_disc_log_entry *e, but e will always be NULL when called via libnvmf_discovery_nbft(). This can result in a segmentation fault when attempting "nvme connect-all --nbft".

Check for NULL pointer before dereferencing.

[...]

Applied, thanks!

[1/1] fabrics: fix NULL dereference in nvmf_update_tls_concat

      commit: 0f4fe4592005b515170bec08af9ccbfe598f8d72

Best regards,

Signature · 1 line
Daniel Wagner <[email protected]>