]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[scsi] Avoid duplicate call to scsicmd_close() on TEST UNIT READY failure
authorMichael Brown <mcb30@ipxe.org>
Sun, 26 Mar 2017 08:21:14 +0000 (11:21 +0300)
committerMichael Brown <mcb30@ipxe.org>
Sun, 26 Mar 2017 08:29:18 +0000 (11:29 +0300)
When the TEST UNIT READY command receives an error response, the
shutdown of the command's block data interface will result in
scsidev_ready() closing the SCSI device.  This will subsequently
result in a duplicate call to scsicmd_close(), leading to an assertion
failure when list_del() is called for the second time.

Fix by removing the command from the list of outstanding commands
before shutting down the command's interfaces.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/drivers/block/scsi.c

index cb4bb94c4522a4dc1468d9946d1769f65d9cb1b9..d51b5cfa5aeb2a130a569c568b750a686cc26210 100644 (file)
@@ -392,11 +392,13 @@ static void scsicmd_close ( struct scsi_command *scsicmd, int rc ) {
                       scsidev, scsicmd->tag, strerror ( rc ) );
        }
 
+       /* Remove from list of commands */
+       list_del ( &scsicmd->list );
+
        /* Shut down interfaces */
        intfs_shutdown ( rc, &scsicmd->scsi, &scsicmd->block, NULL );
 
-       /* Remove from list of commands and drop list's reference */
-       list_del ( &scsicmd->list );
+       /* Drop list's reference */
        scsicmd_put ( scsicmd );
 }