Re: [PATCH] scsi: elx: libefc: potential use after free in efc_nport_vport_del()

From: Daniel Wagner
Date: Mon Aug 19 2024 - 02:57:50 EST


On Thu, Aug 15, 2024 at 02:29:05PM GMT, Dan Carpenter wrote:
> The kref_put() function will call nport->release if the refcount drops
> to zero. The nport->release release function is _efc_nport_free() which
> frees "nport". But then we dereference "nport" on the next line which
> is a use after free. Re-order these lines to avoid the use after free.
>
> Fixes: fcd427303eb9 ("scsi: elx: libefc: SLI and FC PORT state machine interfaces")
> Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
> ---
> From static analysis. Untested. But it seems low risk.

Look reasonable.

Reviewed-by: Daniel Wagner <dwagner@xxxxxxx>