We should always be tallocing resources to a boot option context;
anything else (for example, the discover context) may have a different
lifetime.
In order to enforce this, we change the void *ctx argument to the
context_create functions to a struct discover_boot_option.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
- d_opt->boot_image = create_devpath_resource(opt,
+ d_opt->boot_image = create_devpath_resource(d_opt,
conf->dc->device, value);
if (root) {
conf->dc->device, value);
if (root) {
opt->boot_args = args;
if (initrd) {
opt->boot_args = args;
if (initrd) {
- d_opt->initrd = create_devpath_resource(opt,
+ d_opt->initrd = create_devpath_resource(d_opt,
conf->dc->device, initrd);
opt->description = talloc_asprintf(opt, "%s initrd=%s %s",
conf->dc->device, initrd);
opt->description = talloc_asprintf(opt, "%s initrd=%s %s",
-struct resource *create_devpath_resource(void *ctx,
+struct resource *create_devpath_resource(struct discover_boot_option *opt,
struct discover_device *orig_device,
const char *devpath)
{
struct discover_device *orig_device,
const char *devpath)
{
struct resource *res;
struct pb_url *url;
struct resource *res;
struct pb_url *url;
- res = talloc(ctx, struct resource);
+ res = talloc(opt, struct resource);
pos = strchr(devpath, ':');
pos = strchr(devpath, ':');
-struct resource *create_url_resource(void *ctx, struct pb_url *url)
+struct resource *create_url_resource(struct discover_boot_option *opt,
+ struct pb_url *url)
- res = talloc(ctx, struct resource);
+ res = talloc(opt, struct resource);
res->url = url;
res->resolved = true;
res->url = url;
res->resolved = true;
+struct discover_boot_option;
struct discover_device;
struct device_handler;
struct pb_url;
struct discover_device;
struct device_handler;
struct pb_url;
-struct resource *create_devpath_resource(void *ctx,
+struct resource *create_devpath_resource(struct discover_boot_option *opt,
struct discover_device *orig_device,
const char *devpath);
struct discover_device *orig_device,
const char *devpath);
-struct resource *create_url_resource(void *ctx, struct pb_url *url);
+struct resource *create_url_resource(struct discover_boot_option *opt,
+ struct pb_url *url);
bool resolve_devpath_resource(struct device_handler *dev,
struct resource *res);
bool resolve_devpath_resource(struct device_handler *dev,
struct resource *res);
}
static struct resource *create_yaboot_devpath_resource(
}
static struct resource *create_yaboot_devpath_resource(
+ struct discover_boot_option *opt,
struct conf_context *conf,
const char *path, char **desc_str)
{
struct conf_context *conf,
const char *path, char **desc_str)
{
devpath = talloc_strdup(conf, path);
}
devpath = talloc_strdup(conf, path);
}
- res = create_devpath_resource(conf->dc, conf->dc->device, devpath);
+ res = create_devpath_resource(opt, conf->dc->device, devpath);
if (desc_str)
*desc_str = devpath;
if (desc_str)
*desc_str = devpath;
opt->option->boot_args = talloc_strdup(opt->option, "");
/* Then start the new image. */
opt->option->boot_args = talloc_strdup(opt->option, "");
/* Then start the new image. */
- opt->boot_image = create_yaboot_devpath_resource(conf,
- value, &state->desc_image);
+ opt->boot_image = create_yaboot_devpath_resource(opt,
+ conf, value, &state->desc_image);
state->opt = opt;
if (*value == '/') {
state->opt = opt;
if (*value == '/') {
- opt->boot_image = create_yaboot_devpath_resource(
+ opt->boot_image = create_yaboot_devpath_resource(opt,
conf, value, &state->desc_image);
} else {
char *tmp;
conf, value, &state->desc_image);
} else {
char *tmp;
- opt->boot_image = create_yaboot_devpath_resource(
+ opt->boot_image = create_yaboot_devpath_resource(opt,
conf, suse_fp->image,
&state->desc_image);
conf, suse_fp->image,
&state->desc_image);
- opt->initrd = create_yaboot_devpath_resource(
+ opt->initrd = create_yaboot_devpath_resource(opt,
conf, suse_fp->initrd, &tmp);
state->desc_initrd = talloc_asprintf(opt,
conf, suse_fp->initrd, &tmp);
state->desc_initrd = talloc_asprintf(opt,
/* initrd */
if (streq(name, "initrd")) {
/* initrd */
if (streq(name, "initrd")) {
- opt->initrd = create_yaboot_devpath_resource(conf,
+ opt->initrd = create_yaboot_devpath_resource(opt, conf,
value, &state->desc_image);
return;
value, &state->desc_image);
return;