Stop calling gic_v3_detach when we haven't called gic_v3_attach

The former tries to dereference memory allocated by the latter. If counting
the redistributor fails it may try to dereference memory that was never
allocated.

Sponsored by:	Innovate UK
This commit is contained in:
Andrew Turner 2020-11-17 10:27:42 +00:00
parent a56b066600
commit d2d754c498
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=367755

View File

@ -262,7 +262,7 @@ gic_v3_acpi_attach(device_t dev)
err = gic_v3_acpi_count_regions(dev);
if (err != 0)
goto error;
goto count_error;
err = gic_v3_attach(dev);
if (err != 0)
@ -294,12 +294,13 @@ gic_v3_acpi_attach(device_t dev)
return (0);
error:
/* Failure so free resources */
gic_v3_detach(dev);
count_error:
if (bootverbose) {
device_printf(dev,
"Failed to attach. Error %d\n", err);
}
/* Failure so free resources */
gic_v3_detach(dev);
return (err);
}