Skip closef for property backend

In 50400d3 the selabel_open function was updated to call selabel_close
should the initialization of a backend fails. selabel_close includes a
call to the backend-specific close function: closef. This same function
is previously call, in case of an error, within the init function.

The file backend was adapted by introducing a safe guard to prevent a
double free. Update the property backend in a similar fashion.

Bug: 215387420
Test: build & boot
Change-Id: Id6b7c4d10538ccbec43b2af1de462da077f10c44
This commit is contained in:
Thiébaud Weksteen 2022-01-27 11:36:16 +11:00
parent 2d3cc3b458
commit 98fa1b865d

View file

@ -278,6 +278,12 @@ static void closef(struct selabel_handle *rec)
struct spec *spec;
unsigned int i;
if (!data)
return;
/* make sure successive ->func_close() calls are harmless */
rec->data = NULL;
if (data->spec_arr) {
for (i = 0; i < data->nspec; i++) {
spec = &data->spec_arr[i];