public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Ralph Siemsen <ralph.siemsen@linaro.org>
To: Marek Vasut <marek.vasut@mailbox.org>
Cc: u-boot@lists.denx.de, "Simon Glass" <sjg@chromium.org>,
	"Heiko Thiery" <heiko.thiery@gmail.com>,
	"Heinrich Schuchardt" <xypron.glpk@gmx.de>,
	"Ilias Apalodimas" <ilias.apalodimas@linaro.org>,
	"Marc Kleine-Budde" <mkl@pengutronix.de>,
	"Massimo Pegorer" <massimo.pegorer@vimar.com>,
	"Mattijs Korpershoek" <mkorpershoek@baylibre.com>,
	"Max Krummenacher" <max.krummenacher@toradex.com>,
	"Pali Rohár" <pali@kernel.org>,
	"Roman Kopytin" <Roman.Kopytin@kaspersky.com>,
	"Safae Ouajih" <souajih@baylibre.com>,
	"Sean Anderson" <seanga2@gmail.com>,
	"Steven Lawrance" <steven.lawrance@softathome.com>,
	"Sughosh Ganu" <sughosh.ganu@linaro.org>,
	"Weijie Gao" <weijie.gao@mediatek.com>
Subject: Re: [PATCH v5 09/10] tools: spkgimage: add Renesas SPKG format
Date: Mon, 8 May 2023 13:50:01 -0400	[thread overview]
Message-ID: <20230508175001.GA3380022@maple.netwinder.org> (raw)
In-Reply-To: <97434886-26e1-d607-a7c1-7de6280f7d5a@mailbox.org>

On Sun, May 07, 2023 at 06:08:33PM +0200, Marek Vasut wrote:
>[...]
>
>>+static int spkgimage_parse_config_file(char *filename)
>>+{
>>+	FILE *fcfg;
>>+	char line[256];
>>+	size_t line_num = 0;
>>+
>>+	fcfg = fopen(filename, "r");
>>+	if (!fcfg)
>>+		return -EINVAL;
>>+
>>+	conf = calloc(1, sizeof(struct config_file));
>>+	if (!conf)
>>+		return -ENOMEM;
>>+
>>+	while (fgets(line, sizeof(line), fcfg)) {
>>+		line_num += 1;
>>+
>>+		/* Skip blank lines and comments */
>>+		if (line[0] == '\n' || line[0] == '#')
>>+			continue;
>>+
>>+		/* Strip any trailing newline */
>>+		line[strcspn(line, "\n")] = 0;
>>+
>>+		/* Parse the line */
>>+		if (spkgimage_parse_config_line(line, line_num))
>>+			return -EINVAL;
>
>Wouldn't this return -EINVAL; leak memory allocated by the calloc() above?

You are correct. But note that in the normal (non-error) code path, the 
structure remains allocated as well, and there is no good place to 
free() it, given the available callbacks in struct image_type_params.

So I am relying on the OS to free all memory upon program exit, both in 
the error and non-error case. I would think this is reasonable for a 
small one-shot utility program, keeps things simple.

If this is not acceptable, I can rework it, but there are quite a few 
other spots which would also need to free resources before bailing out.

>[...]
>
>With that fixed:
>
>Reviewed-by: Marek Vasut <marek.vasut+renesas@mailbox.org>

I'll wait to hear back from you before applying this tag.

Regards,
Ralph

  reply	other threads:[~2023-05-08 17:50 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-24  1:15 [PATCH v5 00/10] Renesas RZ/N1 SoC initial support Ralph Siemsen
2023-04-24  1:15 ` [PATCH v5 01/10] ARM: armv7: add non-SPL enable for Cortex SMPEN Ralph Siemsen
2023-04-24  1:15 ` [PATCH v5 02/10] clk: renesas: prepare for non R-Car clock drivers Ralph Siemsen
2023-05-07 15:51   ` Marek Vasut
2023-04-24  1:15 ` [PATCH v5 03/10] clk: renesas: add R906G032 driver Ralph Siemsen
2023-05-07 15:53   ` Marek Vasut
2023-04-24  1:15 ` [PATCH v5 04/10] pinctrl: " Ralph Siemsen
2023-04-24  1:15 ` [PATCH v5 05/10] ram: cadence: add driver for Cadence EDAC Ralph Siemsen
2023-05-07 16:12   ` Marek Vasut
2023-04-24  1:15 ` [PATCH v5 06/10] ARM: dts: add devicetree for Renesas RZ/N1 SoC Ralph Siemsen
2023-05-07 15:54   ` Marek Vasut
2023-04-24  1:15 ` [PATCH v5 07/10] ARM: rmobile: Add support " Ralph Siemsen
2023-05-07 15:57   ` Marek Vasut
2023-04-24  1:15 ` [PATCH v5 08/10] board: schneider: add RZN1 board support Ralph Siemsen
2023-05-07 16:06   ` Marek Vasut
2023-05-08 18:23     ` Ralph Siemsen
2023-05-09  2:26       ` Marek Vasut
2023-05-09 13:21         ` Ralph Siemsen
2023-05-12 20:12           ` Ralph Siemsen
2023-04-24  1:15 ` [PATCH v5 09/10] tools: spkgimage: add Renesas SPKG format Ralph Siemsen
2023-05-07 16:08   ` Marek Vasut
2023-05-08 17:50     ` Ralph Siemsen [this message]
2023-05-09  2:25       ` Marek Vasut
2023-05-09 13:07         ` Ralph Siemsen
2023-05-09 14:52           ` Marek Vasut
2023-05-09 15:42             ` Ralph Siemsen
2023-05-12 20:14               ` Ralph Siemsen
2023-04-24  1:15 ` [PATCH v5 10/10] doc: renesas: add Renesas board docs Ralph Siemsen
2023-05-07 16:10   ` Marek Vasut
  -- strict thread matches above, loose matches on Subject: below --
2023-05-12 20:15 [PATCH v5 00/10] Renesas RZ/N1 SoC initial support Ralph Siemsen
2023-05-12 20:15 ` [PATCH v5 09/10] tools: spkgimage: add Renesas SPKG format Ralph Siemsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230508175001.GA3380022@maple.netwinder.org \
    --to=ralph.siemsen@linaro.org \
    --cc=Roman.Kopytin@kaspersky.com \
    --cc=heiko.thiery@gmail.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=marek.vasut@mailbox.org \
    --cc=massimo.pegorer@vimar.com \
    --cc=max.krummenacher@toradex.com \
    --cc=mkl@pengutronix.de \
    --cc=mkorpershoek@baylibre.com \
    --cc=pali@kernel.org \
    --cc=seanga2@gmail.com \
    --cc=sjg@chromium.org \
    --cc=souajih@baylibre.com \
    --cc=steven.lawrance@softathome.com \
    --cc=sughosh.ganu@linaro.org \
    --cc=u-boot@lists.denx.de \
    --cc=weijie.gao@mediatek.com \
    --cc=xypron.glpk@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox