[<prev] [next>] [day] [month] [year] [list]
Message-ID: <cf6ec3b6-ac2e-e076-2a48-2ed25db4c0f1@web.de>
Date: Sun, 26 Apr 2020 21:50:06 +0200
From: Markus Elfring <Markus.Elfring@....de>
To: Christophe Jaillet <christophe.jaillet@...adoo.fr>,
Alan Tull <atull@...nel.org>
Cc: kernel-janitors@...r.kernel.org, linux-kernel@...r.kernel.org,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Moritz Fischer <mdf@...nel.org>,
Richard Gong <richard.gong@...ux.intel.com>
Subject: Re: [PATCH] firmware: stratix10-svc: Fix some error handling paths in
'stratix10_svc_drv_probe()'
> If an error occurs after calling 'kfifo_alloc()', the allocated memory
> should be freed with 'kfifo_free()', as already done in the remove
> function.
I suggest to reconsider software development consequences around
another implementation detail for such exception handling.
…
> +++ b/drivers/firmware/stratix10-svc.c
> @@ -1043,24 +1043,31 @@ static int stratix10_svc_drv_probe(struct platform_device *pdev)
…
> svc = devm_kzalloc(dev, sizeof(*svc), GFP_KERNEL);
…
> + if (!svc) {
> + ret = -ENOMEM;
> + goto err_free_kfifo;
> + }
Would you like to take the possibility into account to avoid
the duplicate specification of this error code assignment
by adding another jump target?
- return -ENOMEM;
+ goto e_nomem;
>+ return 0;
>+
+e_nomem:
+ ret = -ENOMEM;
>+err_free_kfifo:
>+ kfifo_free(&controller->svc_fifo);
> return ret;
> }
By the way:
How do you think about to omit the error message “failed to allocate FIFO”
for a failed call of the function “kfifo_alloc”?
Regards,
Markus
Powered by blists - more mailing lists