[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87wme683xo.fsf@bootlin.com>
Date: Tue, 04 Feb 2025 10:17:07 +0100
From: Miquel Raynal <miquel.raynal@...tlin.com>
To: Jiasheng Jiang <jiashengjiangcool@...il.com>
Cc: christophe.jaillet@...adoo.fr, gmpy.liaowx@...il.com, kees@...nel.org,
linux-kernel@...r.kernel.org, linux-mtd@...ts.infradead.org,
richard@....at, vigneshr@...com, stable@...r.kernel.org
Subject: Re: [PATCH v2] mtd: Add check and kfree() for kcalloc()
Hello,
> --- a/drivers/mtd/mtdpstore.c
> +++ b/drivers/mtd/mtdpstore.c
> @@ -418,10 +418,17 @@ static void mtdpstore_notify_add(struct mtd_info *mtd)
>
> longcnt = BITS_TO_LONGS(div_u64(mtd->size, info->kmsg_size));
> cxt->rmmap = kcalloc(longcnt, sizeof(long), GFP_KERNEL);
> + if (!cxt->rmmap)
> + goto end;
We prefer to return immediately in this case.
Also, any reasons not to use devm_kcalloc()? This would be the correct
approach as of today as long as the lifetime of the device is known.
Thanks,
Miquèl
Powered by blists - more mailing lists