[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH parted 2/2] _device_unregister: check for unregistering the s
Re: [PATCH parted 2/2] _device_unregister: check for unregistering the same device twice
Fri, 30 Apr 2010 17:44:43 +0200
Hans de Goede wrote:
> _device_unregister() can get called 2 times for the same device if
> a libparted user explictly removes the device from the cache using
> ped_device_cache_remove(), it gets called and it then becomes the
> user's responsibility to free the PedDevice by calling
> ped_device_destroy(). ped_device_destroy() will then call
> _device_unregister() a second time with the same device, so if the
> device is not found in the list, do nothing.
> * libparted/device.c(_device_unregister): Check for unregistering
> the same device twice.
Thank you for the patch.
I've pushed it, with this added to the commit log:
Reported by Jan Stodola in http://bugzilla.redhat.com/568346
That should be enough to create a test suite addition,
if someone finds the time.
> + allow using ped_device_cache_remove(dev) followed by a (later)
> + ped_device_destroy() without corrupting the device cache.
> ** Changes in behavior
> libparted no longer issues an exception/warning about >512-byte
> diff --git a/libparted/device.c b/libparted/device.c
> index f20121b..00f49a3 100644
> --- a/libparted/device.c
> +++ b/libparted/device.c
> @@ -73,6 +73,16 @@ _device_unregister (PedDevice* dev)
> if (walk == dev) break;
> + /* This function may be called twice for the same device if a
> + libparted user explictly removes the device from the cache using
> + ped_device_cache_remove(), we get called and it then becomes the
> + user's responsibility to free the PedDevice by calling
> + ped_device_destroy().
> + ped_device_destroy() will then call us a second time, so if the
> + device is not found in the list do nothing. */
> + if (walk == NULL)
> + return;
> if (last)
> last->next = dev->next;