scsi: lpfc: Fix list corruption detected in lpfc_put_sgl_per_hdwq
authorJames Smart <jsmart2021@gmail.com>
Sun, 22 Sep 2019 03:59:02 +0000 (20:59 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 23 Jan 2020 07:22:59 +0000 (08:22 +0100)
commit287a465e1204f5d2ae26dbb9c9a215e441d832fb
treef8a4ace3e685cf2c43e3d9bed8bd562e0981e443
parent240333d7b1bff70eac5e23ea8761fb84d2f07a28
scsi: lpfc: Fix list corruption detected in lpfc_put_sgl_per_hdwq

commit 35a635af54ce79881eb35ba20b64dcb1e81b0389 upstream.

In lpfc_release_io_buf, an lpfc_io_buf is returned to the 'available' pool
before any associated sgl or cmd and rsp buffers are returned via their
respective 'put' routines.  If xri rebalancing occurs and an lpfc_io_buf
structure is reused quickly, there may be a race condition between release
of old and association of new resources.

Re-ordered lpfc_release_io_buf to release sgl and cmd/rsp
buffer lists before releasing the lpfc_io_buf structure for re-use.

Fixes: d79c9e9d4b3d ("scsi: lpfc: Support dynamic unbounded SGL lists on G7 hardware.")
Link: https://lore.kernel.org/r/20190922035906.10977-17-jsmart2021@gmail.com
Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/scsi/lpfc/lpfc_sli.c