[parted-devel] [PATCH 86/86] parted.c: Make sure dev_name is freed

Brian C. Lane bcl at redhat.com
Wed Jul 25 00:04:46 BST 2018


On Tue, Jul 24, 2018 at 09:45:32AM -0400, Phillip Susi wrote:
> On 7/23/2018 8:26 PM, Brian C. Lane wrote:
> > If there was a problem with ped_device_get or ped_device_open it would not be freed.
> 
> Looks good, but while looking at this I think I spotted another bug.  It
> looks like this path calls ped_device_probe_all() to find all devices on
> the system, then ped_device_free_all() to get rid of them ( why even
> bother?  to save a few bytes of heap? or are they holding open file
> handles that we want to close? ).  Then it tries to re-acquire the
> device that it already had when this started.  In the process of doing
> this though, it will discard any unsaved changes that are represented in
> the previously existing PedDisk that have not been saved to disk yet.
> 
> I think it may need to instead loop over the devices closing them all,
> except for the originally open one, rather than call
> ped_device_free_all().  That also gets rid of the need to strdup the
> name and the rest of the changes in this patch.

That could be, I'll have to dig into that when I have the time. But
let's leave that for a future patch.

-- 
Brian C. Lane (PST8PDT)



More information about the parted-devel mailing list