mi: don't return from mi_mctp_submit with a tag held
authorJeremy Kerr <jk@codeconstruct.com.au>
Wed, 24 May 2023 09:29:33 +0000 (17:29 +0800)
committerDaniel Wagner <wagi@monom.org>
Mon, 3 Jul 2023 06:04:43 +0000 (08:04 +0200)
If the poll() times-out or fails, we'll exit early from
nvme_mi_mctp_submit still holding the tag reservation. When using an i2c
transport, this may mean we hold a lock on the i2c bus with no way to
release.

Instead, always drop the tag on function exit.

Fixes: 6a08780 ("mi-mctp: Add timeout support to MCTP transport")
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
src/nvme/mi-mctp.c

index 0c5972a5677c4bebda2ddd343aebeaf2b12f74c3..a0831576ecf1c4fbef12be49e7be0b0140225e35 100644 (file)
@@ -333,13 +333,14 @@ retry:
                nvme_msg(ep->root, LOG_ERR,
                         "Failed polling on MCTP socket: %m");
                errno = errno_save;
-               return -1;
+               goto out;
        }
 
        if (rc == 0) {
                nvme_msg(ep->root, LOG_DEBUG, "Timeout on MCTP socket");
                errno = ETIMEDOUT;
-               return -1;
+               rc = -1;
+               goto out;
        }
 
        rc = -1;