fix deinitialization of moved composite volume

After moving from a volume, it's priv is assigned to the new owner.
Destroying the volume after moving from it must not attempt to use the
priv, especially not to attempt to deinit member volumes in case of
composite volume.

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
This commit is contained in:
Adam Rutkowski 2022-06-09 10:54:06 +02:00
parent 5a80237e74
commit a7f70687a9

View File

@ -152,6 +152,11 @@ static void ocf_composite_volume_on_deinit(ocf_volume_t cvolume)
struct ocf_composite_volume *composite = ocf_volume_get_priv(cvolume); struct ocf_composite_volume *composite = ocf_volume_get_priv(cvolume);
int i; int i;
/* priv can be NULL if this volume had been moved from. In this case
* it's the owner responsibility to deinit member volumes. */
if (!composite)
return;
for (i = 0; i < composite->members_cnt; i++) for (i = 0; i < composite->members_cnt; i++)
ocf_volume_deinit(&composite->member[i].volume); ocf_volume_deinit(&composite->member[i].volume);
} }