Do not leak resources during attach if nvme_ctrlr_construct() or the initial
controller resets fail. Sponsored by: Intel Reviewed by: carl Approved by: re (hrs) MFC after: 1 week
This commit is contained in:
parent
bb2f67fd72
commit
7aa27dbac5
@ -221,8 +221,10 @@ nvme_attach(device_t dev)
|
||||
|
||||
status = nvme_ctrlr_construct(ctrlr, dev);
|
||||
|
||||
if (status != 0)
|
||||
if (status != 0) {
|
||||
nvme_ctrlr_destruct(ctrlr, dev);
|
||||
return (status);
|
||||
}
|
||||
|
||||
/*
|
||||
* Reset controller twice to ensure we do a transition from cc.en==1
|
||||
@ -230,12 +232,16 @@ nvme_attach(device_t dev)
|
||||
* the controller was left in when boot handed off to OS.
|
||||
*/
|
||||
status = nvme_ctrlr_hw_reset(ctrlr);
|
||||
if (status != 0)
|
||||
if (status != 0) {
|
||||
nvme_ctrlr_destruct(ctrlr, dev);
|
||||
return (status);
|
||||
}
|
||||
|
||||
status = nvme_ctrlr_hw_reset(ctrlr);
|
||||
if (status != 0)
|
||||
if (status != 0) {
|
||||
nvme_ctrlr_destruct(ctrlr, dev);
|
||||
return (status);
|
||||
}
|
||||
|
||||
nvme_sysctl_initialize_ctrlr(ctrlr);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user