return rc;
 }
 
-/**
- * lpfc_ras_stop_fwlog: Disable FW logging by the adapter
- * @phba: Pointer to HBA context object.
- *
- * Disable FW logging into host memory on the adapter. To
- * be done before reading logs from the host memory.
- **/
-static void
-lpfc_ras_stop_fwlog(struct lpfc_hba *phba)
-{
-       struct lpfc_ras_fwlog *ras_fwlog = &phba->ras_fwlog;
-
-       ras_fwlog->ras_active = false;
-
-       /* Disable FW logging to host memory */
-       writel(LPFC_CTL_PDEV_CTL_DDL_RAS,
-              phba->sli4_hba.conf_regs_memmap_p + LPFC_CTL_PDEV_CTL_OFFSET);
-}
-
 /**
  * lpfc_bsg_set_ras_config: Set FW logging parameters
  * @job: fc_bsg_job to handle
        if (!ras_fwlog->lwpd.virt) {
                lpfc_printf_log(phba, KERN_ERR, LOG_LIBDFC,
                                "6193 Restart FW Logging\n");
-               return -EINVAL;
+               rc = -EINVAL;
+               goto ras_job_error;
        }
 
        /* Get lwpd offset */
 
 void lpfc_sli4_ras_setup(struct lpfc_hba *phba);
 int  lpfc_sli4_ras_fwlog_init(struct lpfc_hba *phba, uint32_t fwlog_level,
                         uint32_t fwlog_enable);
+void lpfc_ras_stop_fwlog(struct lpfc_hba *phba);
 int lpfc_check_fwlog_support(struct lpfc_hba *phba);
 
 /* NVME interfaces. */
 
        kthread_stop(phba->worker_thread);
 
        /* Disable FW logging to host memory */
-       writel(LPFC_CTL_PDEV_CTL_DDL_RAS,
-              phba->sli4_hba.conf_regs_memmap_p + LPFC_CTL_PDEV_CTL_OFFSET);
-
-       /* Free RAS DMA memory */
-       if (phba->ras_fwlog.ras_enabled == true)
-               lpfc_sli4_ras_dma_free(phba);
+       lpfc_ras_stop_fwlog(phba);
 
        /* Unset the queues shared with the hardware then release all
         * allocated resources.
        /* Reset SLI4 HBA FCoE function */
        lpfc_pci_function_reset(phba);
 
+       /* Free RAS DMA memory */
+       if (phba->ras_fwlog.ras_enabled)
+               lpfc_sli4_ras_dma_free(phba);
+
        /* Stop the SLI4 device port */
        phba->pport->work_port_events = 0;
 }
 
        return;
 }
 
+/**
+ * lpfc_ras_stop_fwlog: Disable FW logging by the adapter
+ * @phba: Pointer to HBA context object.
+ *
+ * Disable FW logging into host memory on the adapter. To
+ * be done before reading logs from the host memory.
+ **/
+void
+lpfc_ras_stop_fwlog(struct lpfc_hba *phba)
+{
+       struct lpfc_ras_fwlog *ras_fwlog = &phba->ras_fwlog;
+
+       ras_fwlog->ras_active = false;
+
+       /* Disable FW logging to host memory */
+       writel(LPFC_CTL_PDEV_CTL_DDL_RAS,
+              phba->sli4_hba.conf_regs_memmap_p + LPFC_CTL_PDEV_CTL_OFFSET);
+}
+
 /**
  * lpfc_sli4_ras_dma_free - Free memory allocated for FW logging.
  * @phba: Pointer to HBA context object.