Page MenuHomeFreeBSD

bhyve(8) pci_xhci.c elliminate possible double free of uopt
ClosedPublic

Authored by rgrimes on Feb 14 2019, 8:00 PM.

Details

Summary

In r340044 an attempt to quiet coverity warning cid 1357336 was incorrectly implemented leading to a possible double free.

It is possible for both the conditional free, and the unconditional free added in r340044 to be done, fix that by initializing uopt to NULL, removing the conditional free, and only using the unconditional free at the end.

Brought to my attention by Patrick Mooney of Joyent/illumos

Test Plan

Visial code inspection, and compile tested.

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

rgrimes created this revision.Feb 14 2019, 8:00 PM

This is the fix we're applying to SmartOS bhyve, after syncing from upstream.

jhb accepted this revision.Feb 14 2019, 8:15 PM
jhb added inline comments.
usr.sbin/bhyve/pci_xhci.c
2629 ↗(On Diff #53936)

style nit would be to initialize the value on a separate line here rather than in the declaration.

This revision is now accepted and ready to land.Feb 14 2019, 8:15 PM
rgrimes updated this revision to Diff 53937.Feb 14 2019, 8:23 PM

Move initialization of uopt to after declares addressing jhb style(9) issue

This revision now requires review to proceed.Feb 14 2019, 8:23 PM
rgrimes marked an inline comment as done.Feb 14 2019, 8:23 PM

Address jhb style 9 issues

usr.sbin/bhyve/pci_xhci.c
2629 ↗(On Diff #53936)

You are correct, I applied my minimal lines of diff and no style correction. I should of just added a line after the declares to initialize it, as that achives the same result.

rgrimes marked an inline comment as done.Feb 14 2019, 8:24 PM
This revision was not accepted when it landed; it landed in state Needs Review.Feb 15 2019, 4:48 PM
This revision was automatically updated to reflect the committed changes.