Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AD458C4332F for ; Tue, 13 Dec 2022 13:37:59 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 894CC85420; Tue, 13 Dec 2022 14:37:56 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=konsulko.com header.i=@konsulko.com header.b="YQg+9hZS"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7F4FB85432; Tue, 13 Dec 2022 14:37:54 +0100 (CET) Received: from mail-vs1-xe36.google.com (mail-vs1-xe36.google.com [IPv6:2607:f8b0:4864:20::e36]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3C8AC84EA1 for ; Tue, 13 Dec 2022 14:37:51 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=trini@konsulko.com Received: by mail-vs1-xe36.google.com with SMTP id c184so14613188vsc.3 for ; Tue, 13 Dec 2022 05:37:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=ABKo0JyBhvAsqf1d/OSKk+c6qG8GuvwpT7Al5PV2krk=; b=YQg+9hZSumw2fXztqACa6Xx0uytTVLW6z4TtGNs36DBdnAfzws3eo/87rBQ1TXnF4Z YI82YQjfXzmDqV6sriyEbNtKueoe0z7/b9+kpD3WSDsJBXeBOrln0xgh12nAM4WpjVmw 0fnK0qfNeaT0OCz7qKn2dulTc+offRHdYfk+c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ABKo0JyBhvAsqf1d/OSKk+c6qG8GuvwpT7Al5PV2krk=; b=UbSF+FCacTqmRJpcYRy+acfczYpHDaigqhkOFSdp20+A7ggjON+mE9/L8WQ8+o9sgA sKhCM0t5Vyo7dK2UtojS/sblRs/Drl7MqgtGaWvbAlFVUxg+/c27kJcpkVI3MlJ94Gf2 cpoNRj5Xm5o+23HGTeuUvLpei7nLowYcCOtYa5Ael4NXtHwybn6sjaDLZ1DjIeBGSf7y 02dlc2UbkQGkVg9Tjva08UQJSsgjb4zhZXHqxyJgAONZoYFWrWA0sW+eEWXi5HUUgwhv /JiPcSq5AJf8KC65bqZ5wXK6fKKyjlIkopMZ2od4Z3/8R+T7kVoOD/C9dGS5IQ7HjMgh hWBg== X-Gm-Message-State: ANoB5pmDShHFXozA5VqyaPH1TI1nbprFg0lx47BFr5PZ8T3SLD3DW5k0 EvK40AIalTGk3lndDHZB3GTfzVfEc8ogkb9b X-Google-Smtp-Source: AA0mqf7eA6OGhpafF5/XGLsjEDZCt3WGxSqR+d5YXHph11AkKHS+C8Bm++AAKqjy5J/9xitg5UEIRw== X-Received: by 2002:a05:6102:946:b0:3aa:f64:b4ee with SMTP id a6-20020a056102094600b003aa0f64b4eemr14459353vsi.12.1670938669727; Tue, 13 Dec 2022 05:37:49 -0800 (PST) Received: from bill-the-cat.lan (2603-6081-7b00-6400-09de-b540-f7da-b28e.res6.spectrum.com. [2603:6081:7b00:6400:9de:b540:f7da:b28e]) by smtp.gmail.com with ESMTPSA id s8-20020a05620a29c800b006fba0a389a4sm8083415qkp.88.2022.12.13.05.37.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Dec 2022 05:37:49 -0800 (PST) From: Tom Rini To: u-boot@lists.denx.de Cc: Neil Armstrong , Patrick Delaunay , Quentin Schulz Subject: [PATCH] Revert "cmd: pxe: use strdup to copy config" et al Date: Tue, 13 Dec 2022 08:37:48 -0500 Message-Id: <20221213133748.1283705-1-trini@konsulko.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean This reverts commits 51c5c28af59c ("cmd: pxe: use strdup to copy config"), a5dacef7380e ("cmd: pxe: support INITRD and FDT selection with FIT") and f723c2778cf8 ("cmd: pxe: reorder kernel treatment in label_boot"). As reported by Quentin Schulz, this introduces a regression with previously generated and working extlinux.conf files. Cc: Neil Armstrong Cc: Patrick Delaunay Reported-by: Quentin Schulz Signed-off-by: Tom Rini --- boot/pxe_utils.c | 69 ++++++++++++++++++++------------------------- doc/README.pxe | 8 ------ include/pxe_utils.h | 2 -- 3 files changed, 30 insertions(+), 49 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index 272431381763..075a0f28309e 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -258,7 +258,6 @@ static struct pxe_label *label_create(void) static void label_destroy(struct pxe_label *label) { free(label->name); - free(label->kernel_label); free(label->kernel); free(label->config); free(label->append); @@ -522,44 +521,28 @@ static int label_boot(struct pxe_context *ctx, struct pxe_label *label) return 1; } - if (get_relfile_envaddr(ctx, label->kernel, "kernel_addr_r", - NULL) < 0) { - printf("Skipping %s for failure retrieving kernel\n", - label->name); - return 1; - } - - kernel_addr = env_get("kernel_addr_r"); - /* for FIT, append the configuration identifier */ - if (label->config) { - int len = strlen(kernel_addr) + strlen(label->config) + 1; - - fit_addr = malloc(len); - if (!fit_addr) { - printf("malloc fail (FIT address)\n"); - return 1; - } - snprintf(fit_addr, len, "%s%s", kernel_addr, label->config); - kernel_addr = fit_addr; - } - - /* For FIT, the label can be identical to kernel one */ - if (label->initrd && !strcmp(label->kernel_label, label->initrd)) { - initrd_addr_str = kernel_addr; - } else if (label->initrd) { + if (label->initrd) { ulong size; + if (get_relfile_envaddr(ctx, label->initrd, "ramdisk_addr_r", &size) < 0) { printf("Skipping %s for failure retrieving initrd\n", label->name); - goto cleanup; + return 1; } initrd_addr_str = env_get("ramdisk_addr_r"); size = snprintf(initrd_str, sizeof(initrd_str), "%s:%lx", initrd_addr_str, size); if (size >= sizeof(initrd_str)) - goto cleanup; + return 1; + } + + if (get_relfile_envaddr(ctx, label->kernel, "kernel_addr_r", + NULL) < 0) { + printf("Skipping %s for failure retrieving kernel\n", + label->name); + return 1; } if (label->ipappend & 0x1) { @@ -589,7 +572,7 @@ static int label_boot(struct pxe_context *ctx, struct pxe_label *label) strlen(label->append ?: ""), strlen(ip_str), strlen(mac_str), sizeof(bootargs)); - goto cleanup; + return 1; } if (label->append) @@ -604,6 +587,21 @@ static int label_boot(struct pxe_context *ctx, struct pxe_label *label) printf("append: %s\n", finalbootargs); } + kernel_addr = env_get("kernel_addr_r"); + + /* for FIT, append the configuration identifier */ + if (label->config) { + int len = strlen(kernel_addr) + strlen(label->config) + 1; + + fit_addr = malloc(len); + if (!fit_addr) { + printf("malloc fail (FIT address)\n"); + return 1; + } + snprintf(fit_addr, len, "%s%s", kernel_addr, label->config); + kernel_addr = fit_addr; + } + /* * fdt usage is optional: * It handles the following scenarios. @@ -625,11 +623,8 @@ static int label_boot(struct pxe_context *ctx, struct pxe_label *label) */ bootm_argv[3] = env_get("fdt_addr_r"); - /* For FIT, the label can be identical to kernel one */ - if (label->fdt && !strcmp(label->kernel_label, label->fdt)) { - bootm_argv[3] = kernel_addr; /* if fdt label is defined then get fdt from server */ - } else if (bootm_argv[3]) { + if (bootm_argv[3]) { char *fdtfile = NULL; char *fdtfilefree = NULL; @@ -1170,19 +1165,15 @@ static int parse_label_kernel(char **c, struct pxe_label *label) if (err < 0) return err; - /* copy the kernel label to compare with FDT / INITRD when FIT is used */ - label->kernel_label = strdup(label->kernel); - if (!label->kernel_label) - return -ENOMEM; - s = strstr(label->kernel, "#"); if (!s) return 1; - label->config = strdup(s); + label->config = malloc(strlen(s) + 1); if (!label->config) return -ENOMEM; + strcpy(label->config, s); *s = 0; return 1; diff --git a/doc/README.pxe b/doc/README.pxe index 172201093d02..d14d2bdcc9b0 100644 --- a/doc/README.pxe +++ b/doc/README.pxe @@ -179,19 +179,11 @@ initrd - if this label is chosen, use tftp to retrieve the initrd at . it will be stored at the address indicated in the initrd_addr_r environment variable, and that address will be passed to bootm. - For FIT image, the initrd can be provided with the same value than - kernel, including configuration: - #[# - if this label is chosen, use tftp to retrieve the fdt blob at . it will be stored at the address indicated in the fdt_addr_r environment variable, and that address will be passed to bootm. - For FIT image, the device tree can be provided with the same value - than kernel, including configuration: - #[# - if this label is chosen, use tftp to retrieve the fdt blob at . it will be stored at the address indicated in diff --git a/include/pxe_utils.h b/include/pxe_utils.h index 1e5e8424f53f..4a73b2aace34 100644 --- a/include/pxe_utils.h +++ b/include/pxe_utils.h @@ -28,7 +28,6 @@ * Create these with the 'label_create' function given below. * * name - the name of the menu as given on the 'menu label' line. - * kernel_label - the kernel label, including FIT config if present. * kernel - the path to the kernel file to use for this label. * append - kernel command line to use when booting this label * initrd - path to the initrd to use for this label. @@ -41,7 +40,6 @@ struct pxe_label { char num[4]; char *name; char *menu; - char *kernel_label; char *kernel; char *config; char *append; -- 2.25.1