public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Salah Triki <salah.triki@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] dio: return -ENOMEM when kzalloc() fails
Date: Fri, 2 Jul 2021 16:44:07 +0200	[thread overview]
Message-ID: <YN8mN3mtRH+S6D3o@kroah.com> (raw)
In-Reply-To: <20210702133114.GA314157@pc>

On Fri, Jul 02, 2021 at 02:31:14PM +0100, Salah Triki wrote:
> Return -ENOMEM when kzalloc() fails in order to inform the caller of the
> failure.
> 
> Signed-off-by: Salah Triki <salah.triki@gmail.com>
> ---
>  drivers/dio/dio.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/dio/dio.c b/drivers/dio/dio.c
> index 193b40e7aec0..4c06c93c93d3 100644
> --- a/drivers/dio/dio.c
> +++ b/drivers/dio/dio.c
> @@ -219,7 +219,7 @@ static int __init dio_init(void)
>                  /* Found a board, allocate it an entry in the list */
>  		dev = kzalloc(sizeof(struct dio_dev), GFP_KERNEL);
>  		if (!dev)
> -			return 0;
> +			return -ENOMEM;

Do you have this hardware to test with?

While this patch looks correct, it still is leaking lots of resources if
this every happens.  Can you fix this up "properly" so that all of the
resources allocated at this point in time will be correctly freed?

Or, really, this is an impossible error path to hit, given that it is at
boot time, so maybe it's just not worth it given that I doubt anyone has
this hardware...

thanks,

greg k-h

      reply	other threads:[~2021-07-02 14:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-02 13:31 [PATCH] dio: return -ENOMEM when kzalloc() fails Salah Triki
2021-07-02 14:44 ` Greg KH [this message]

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=YN8mN3mtRH+S6D3o@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=salah.triki@gmail.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