On 8/11/2016 7:30 AM, Brian C. Lane wrote:
On Fri, Jul 08, 2016 at 10:04:07AM +0200, Hendrik Brueckner wrote:

+       if (anchor->f4 != NULL)
+               free(anchor->f4);
+       if (anchor->f5 != NULL)
+               free(anchor->f5);
+       if (anchor->f7 != NULL)
+               free(anchor->f7);
+       if (anchor->vlabel != NULL)
+               free(anchor->vlabel);
Should these be set to NULL as they're freed? I can't tell if it's
possible for this to be called again. They weren't before so it may be
just fine.

This function will be called when to release the resource of fdasd_anchor_t.
When this data is freed, parted will stop processing device and exit.
So it is not recalled. And I think it is safe when any one of these data set is NULL and this function is called. This situation may take place in fdasd_initialize_anchor. This function always pairs with fdasd_initialize_anchor in which all the data sets will
be allocated with some resource, or NULL if failed.

When it fails to initialize one data set in some case, parted will complain with error and exit. Then it needs to free the resource allocated to other data set. Then it will avoid
to free the NULL pointer.

Well, it may be much safer to set the freed pointer to NULL explicitly. I will consider this.

Best regards.

Wang Dong

Reply via email to