Commit 6267faa
mi-mctp: Fix free() in error path of mi_open_mctp
If the malloc of our struct nvme_mi_transport_mctp fails, we'll attempt
to free ->rsp_buf of this (now zero) pointer.
Instead, structure the error path to progressively undo the
initialisation operations. This means we'll need to save the errno at
the site of each possible failure.
In doing this, add a comment to the call to nvme_mi_close(), just to
clarify behaviour with regards to the cleanups through that path.
Reported-by: Barnabás Pőcze <[email protected]>
Signed-off-by: Jeremy Kerr <[email protected]>1 parent 3edef73 commit 6267faa
1 file changed
Lines changed: 18 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
472 | 472 | | |
473 | 473 | | |
474 | 474 | | |
475 | | - | |
476 | | - | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
477 | 479 | | |
478 | 480 | | |
479 | 481 | | |
480 | 482 | | |
481 | 483 | | |
482 | 484 | | |
483 | | - | |
484 | | - | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
485 | 489 | | |
486 | 490 | | |
487 | 491 | | |
488 | 492 | | |
489 | 493 | | |
490 | | - | |
491 | | - | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
492 | 498 | | |
493 | 499 | | |
494 | 500 | | |
| |||
504 | 510 | | |
505 | 511 | | |
506 | 512 | | |
507 | | - | |
508 | | - | |
509 | | - | |
| 513 | + | |
510 | 514 | | |
| 515 | + | |
511 | 516 | | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
512 | 521 | | |
513 | 522 | | |
514 | 523 | | |
| |||
0 commit comments