> -----Original Message----- > From: peter.crosthwa...@petalogix.com > On Tue, Aug 19, 2014 at 7:41 PM, <arei.gong...@huawei.com> wrote: > > From: Gonglei <arei.gong...@huawei.com> > > > > At present, the local variable local_err is reused at multi-places, > > Which will cause resource leak in some scenarios. > > > > The problem isn't really the local_err reusage. It's the fact that > this function doesn't have partial cleanup implemented (the > dc->unrealize call you add here is needed but not in original code at > all). Doing a fuller audit of the function, it seems to have outgrown > the simplistic if (!local_err) approach to error handling. I think the > goto-fallthrough system might be a cleaner alternative. Perhaps finish > the fn with: > > dev->realized = value; > return; > > post_realize_fail: > if (dc->unrealize) { > dc->unrealize(dev, NULL); > } > fail: > if (local_err != NULL) { > error_propagate(errp, local_err); > return; > } > > } > > Then goto the appropriate error label as local_err population is > detected as each relevant point. > Hi, Peter. I know your mean. vmstate_unregister() also should be called, beside dc->unrealized().
I will re-realize as your suggestion. Thanks! Best regards, -Gonglei