[parted-devel] Bug: Removal of BLKPG causes regression of ability to manipulate disks with other partitions in use
Petr Uzel
petr.uzel at suse.cz
Tue Apr 6 12:55:43 UTC 2010
On Tue, Mar 30, 2010 at 03:37:38PM -0400, Phillip Susi wrote:
> How do these look? By the way, why are we using ped_malloc() and not
> ped_free()? Passing a pointer to free() that did not come from malloc()
> is an error, so only works as long as ped_malloc() is just a wrapper for
> malloc(), and if that has to be the case, what is the point of ped_malloc()?
[...]
> + if (!rets[i - 1] && errnums[i - 1] == EBUSY) {
> + struct hd_geometry geom;
> + int fd;
> + unsigned long long length = 0;
> + /* get start and length of existing partition */
> + char *dev_name = _device_get_part_path (disk->dev, i);
> + if (!dev_name)
> + goto free_errnums;
> + fd = open (dev_name, O_RDONLY);
> + free (dev_name);
> + if (fd == -1 ||
> + ioctl (fd, HDIO_GETGEO, &geom) ||
> + ioctl (fd, BLKGETSIZE64, &length)) {
> + ped_exception_throw (
> + PED_EXCEPTION_BUG,
> + PED_EXCEPTION_CANCEL,
> + _("Unable to determine the size and length of %s."),
> + dev_name);
Here, dev_name is used after it has been freed. ^^^^
> + if( fd != -1 )
> + close (fd);
> + goto free_errnums;
> + }
Petr
--
Petr Uzel, openSUSE Boosters Team
IRC: ptr_uzl @ freenode
More information about the parted-devel
mailing list