public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: Christophe Jaillet <christophe.jaillet@wanadoo.fr>,
	Alan Tull <atull@kernel.org>
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Moritz Fischer <mdf@kernel.org>,
	Richard Gong <richard.gong@linux.intel.com>
Subject: Re: [PATCH] firmware: stratix10-svc: Fix some error handling paths in 'stratix10_svc_drv_probe()'
Date: Sun, 26 Apr 2020 21:50:06 +0200	[thread overview]
Message-ID: <cf6ec3b6-ac2e-e076-2a48-2ed25db4c0f1@web.de> (raw)

> 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

             reply	other threads:[~2020-04-26 19:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-26 19:50 Markus Elfring [this message]
  -- strict thread matches above, loose matches on Subject: below --
2020-04-26 19:03 [PATCH] firmware: stratix10-svc: Fix some error handling paths in 'stratix10_svc_drv_probe()' Christophe JAILLET
2020-04-28 11:55 ` Dan Carpenter
2020-04-28 20:13   ` Christophe JAILLET

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=cf6ec3b6-ac2e-e076-2a48-2ed25db4c0f1@web.de \
    --to=markus.elfring@web.de \
    --cc=atull@kernel.org \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mdf@kernel.org \
    --cc=richard.gong@linux.intel.com \
    /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