From: Benjamin Block <bblock@linux.ibm.com>
To: "James E.J. Bottomley" <jejb@linux.ibm.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Julian Wiedmann <jwi@linux.ibm.com>,
Benjamin Block <bblock@linux.ibm.com>,
Steffen Maier <maier@linux.ibm.com>,
Heiko Carstens <hca@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Christian Borntraeger <borntraeger@de.ibm.com>,
Fedor Loshakov <loshakov@linux.ibm.com>,
Sumangala Bannur Subraya <bsuma@linux.ibm.com>,
linux-scsi@vger.kernel.org, linux-s390@vger.kernel.org
Subject: [PATCH 3/6] zfcp: fix sysfs roll-back on error in zfcp_adapter_enqueue()
Date: Wed, 14 Apr 2021 19:08:01 +0200 [thread overview]
Message-ID: <790922cc3af075795fff9a4b787e6bda19bdb3be.1618417667.git.bblock@linux.ibm.com> (raw)
In-Reply-To: <cover.1618417667.git.bblock@linux.ibm.com>
From: Julian Wiedmann <jwi@linux.ibm.com>
When zfcp_adapter_enqueue() fails to create the zfcp_sysfs_adapter_attrs
group, it calls zfcp_adapter_unregister() to tear down the adapter state
again. This then unconditionally attempts to remove the
zfcp_sysfs_adapter_attrs group, resulting in a "group not found" WARN
from sysfs code.
Avoid this by copying most of zfcp_adapter_unregister() into the error
path, allowing for more fine-granular roll-back. Then skip the sysfs
tear-down steps if we haven't progressed this far in the initialization.
Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com>
Reviewed-by: Benjamin Block <bblock@linux.ibm.com>
Reviewed-by: Steffen Maier <maier@linux.ibm.com>
Signed-off-by: Benjamin Block <bblock@linux.ibm.com>
---
drivers/s390/scsi/zfcp_aux.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/drivers/s390/scsi/zfcp_aux.c b/drivers/s390/scsi/zfcp_aux.c
index 768873dd55b8..abad77694e72 100644
--- a/drivers/s390/scsi/zfcp_aux.c
+++ b/drivers/s390/scsi/zfcp_aux.c
@@ -418,7 +418,7 @@ struct zfcp_adapter *zfcp_adapter_enqueue(struct ccw_device *ccw_device)
goto failed;
if (zfcp_diag_sysfs_setup(adapter))
- goto failed;
+ goto err_diag_sysfs;
/* report size limit per scatter-gather segment */
adapter->ccw_device->dev.dma_parms = &adapter->dma_parms;
@@ -427,8 +427,24 @@ struct zfcp_adapter *zfcp_adapter_enqueue(struct ccw_device *ccw_device)
return adapter;
+err_diag_sysfs:
+ sysfs_remove_group(&ccw_device->dev.kobj, &zfcp_sysfs_adapter_attrs);
failed:
- zfcp_adapter_unregister(adapter);
+ /* TODO: make this more fine-granular */
+ cancel_delayed_work_sync(&adapter->scan_work);
+ cancel_work_sync(&adapter->stat_work);
+ cancel_work_sync(&adapter->ns_up_work);
+ cancel_work_sync(&adapter->version_change_lost_work);
+ zfcp_destroy_adapter_work_queue(adapter);
+
+ zfcp_fc_wka_ports_force_offline(adapter->gs);
+ zfcp_scsi_adapter_unregister(adapter);
+
+ zfcp_erp_thread_kill(adapter);
+ zfcp_dbf_adapter_unregister(adapter);
+ zfcp_qdio_destroy(adapter->qdio);
+
+ zfcp_ccw_adapter_put(adapter); /* final put to release */
return ERR_PTR(-ENOMEM);
}
--
2.30.2
next prev parent reply other threads:[~2021-04-14 17:08 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-14 17:07 [PATCH 0/6] zfcp: cleanups and qdio code refactor for 5.13/5.14 Benjamin Block
2021-04-14 17:07 ` [PATCH 1/6] zfcp: remove unneeded INIT_LIST_HEAD() for FSF requests Benjamin Block
2021-04-14 17:08 ` [PATCH 2/6] zfcp: fix indentation coding style issue Benjamin Block
2021-04-14 17:08 ` Benjamin Block [this message]
2021-04-14 17:08 ` [PATCH 4/6] zfcp: clean up sysfs code for SFP diagnostics Benjamin Block
2021-04-14 17:08 ` [PATCH 5/6] scsi: zfcp: move the position of put_device Benjamin Block
2021-04-14 17:08 ` [PATCH 6/6] scsi: zfcp: lift Request Queue tasklet & timer from qdio Benjamin Block
2021-04-16 2:20 ` [PATCH 0/6] zfcp: cleanups and qdio code refactor for 5.13/5.14 Martin K. Petersen
2021-04-18 16:04 ` Benjamin Block
2021-04-20 2:29 ` Martin K. Petersen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=790922cc3af075795fff9a4b787e6bda19bdb3be.1618417667.git.bblock@linux.ibm.com \
--to=bblock@linux.ibm.com \
--cc=borntraeger@de.ibm.com \
--cc=bsuma@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=jejb@linux.ibm.com \
--cc=jwi@linux.ibm.com \
--cc=linux-s390@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=loshakov@linux.ibm.com \
--cc=maier@linux.ibm.com \
--cc=martin.petersen@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox