Some resource allocated and not correctly freed in usr.sbin/bhyve/block_if.c.
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Skipped - Unit
Tests Skipped
Event Timeline
| usr.sbin/bhyve/block_if.c | ||
|---|---|---|
| 684 | What are the scenarios where we end up in the err: label with the bc already allocated? Last time we jump to the err label is when bc allocation fails, so still nothing to clean up at this point, and then we don't seem to end up there at all. | |
| 881 | I think style(9) says to declare variables before statements. | |
| usr.sbin/bhyve/block_if.c | ||
|---|---|---|
| 685–687 | Unfortunately we have no way of knowing whether these were successfully created since we don't check for the return values of pthread_{mutex,cond}_* calls above. Could you please add those checks and adjust the cleanup code accordingly? | |
| usr.sbin/bhyve/block_if.c | ||
|---|---|---|
| 684 | Without your internal changes the diff looks strange. Why not to free resources right in the block where if (bc == NULL) {? In case you are not going to upstream your other changes, the best way would be to make the upstreamed change styled correctly: destroy resources right after calloc() failure, then refactor your internal changes upon that. For example you can goto up the code to fall into the beginning of the if (bc == NULL) { block. | |
| 685–687 | And pthread_create, which is way more likely to fail. NB: This function may benefit from __attribute__((cleanup)). I don't know if we already have a precedence of using it in src. | |