All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Allen Pais <allen.lkml@gmail.com>
Cc: linux-fbdev@vger.kernel.org, linux-scsi@vger.kernel.org,
	nouveau@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	dri-devel@lists.freedesktop.org, target-devel@vger.kernel.org,
	linux-crypto@vger.kernel.org, netdev@vger.kernel.org,
	linux-btrfs@vger.kernel.org, MPT-FusionLinux.pdl@broadcom.com,
	megaraidlinux.pdl@broadcom.com
Subject: Re: [PATCH 06/10] drivers:ethernet: return -ENOMEM on allocation failure.
Date: Wed, 13 Sep 2017 14:16:28 +0200	[thread overview]
Message-ID: <20170913121628.GB11820@lunn.ch> (raw)
In-Reply-To: <1505287939-14106-6-git-send-email-allen.lkml@gmail.com>

On Wed, Sep 13, 2017 at 01:02:15PM +0530, Allen Pais wrote:
> Signed-off-by: Allen Pais <allen.lkml@gmail.com>
> ---
>  drivers/net/ethernet/sun/cassini.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/sun/cassini.c b/drivers/net/ethernet/sun/cassini.c
> index 382993c..fc0ea3a 100644
> --- a/drivers/net/ethernet/sun/cassini.c
> +++ b/drivers/net/ethernet/sun/cassini.c
> @@ -3984,7 +3984,7 @@ static inline int cas_alloc_rx_desc(struct cas *cp, int ring)
>  	size = RX_DESC_RINGN_SIZE(ring);
>  	for (i = 0; i < size; i++) {
>  		if ((page[i] = cas_page_alloc(cp, GFP_KERNEL)) == NULL)
> -			return -1;
> +			return -ENOMEM;
>  	}
>  	return 0;
>  }

static int cas_alloc_rxds(struct cas *cp)
{
	int i;

	for (i = 0; i < N_RX_DESC_RINGS; i++) {
		if (cas_alloc_rx_desc(cp, i) < 0) {
	       		cas_free_rxds(cp);
			return -1;
		}
	}
	return 0;
}

Again, your change is correct, but in the end the value is not used.
And if you fix it at the cas_alloc_rxds level, you also need a fix at
the next level up:

	err = -ENOMEM;
	if (cas_tx_tiny_alloc(cp) < 0)
		goto err_unlock;

	/* alloc rx descriptors */
	if (cas_alloc_rxds(cp) < 0)
		goto err_tx_tiny;

again, the return value is discarded.

       Andrew
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

WARNING: multiple messages have this Message-ID (diff)
From: Andrew Lunn <andrew@lunn.ch>
To: Allen Pais <allen.lkml@gmail.com>
Cc: linux-kernel@vger.kernel.org, nouveau@lists.freedesktop.org,
	linux-crypto@vger.kernel.org, dri-devel@lists.freedesktop.org,
	MPT-FusionLinux.pdl@broadcom.com, linux-scsi@vger.kernel.org,
	netdev@vger.kernel.org, megaraidlinux.pdl@broadcom.com,
	target-devel@vger.kernel.org, linux-fbdev@vger.kernel.org,
	linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 06/10] drivers:ethernet: return -ENOMEM on allocation failure.
Date: Wed, 13 Sep 2017 14:16:28 +0200	[thread overview]
Message-ID: <20170913121628.GB11820@lunn.ch> (raw)
In-Reply-To: <1505287939-14106-6-git-send-email-allen.lkml@gmail.com>

On Wed, Sep 13, 2017 at 01:02:15PM +0530, Allen Pais wrote:
> Signed-off-by: Allen Pais <allen.lkml@gmail.com>
> ---
>  drivers/net/ethernet/sun/cassini.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/sun/cassini.c b/drivers/net/ethernet/sun/cassini.c
> index 382993c..fc0ea3a 100644
> --- a/drivers/net/ethernet/sun/cassini.c
> +++ b/drivers/net/ethernet/sun/cassini.c
> @@ -3984,7 +3984,7 @@ static inline int cas_alloc_rx_desc(struct cas *cp, int ring)
>  	size = RX_DESC_RINGN_SIZE(ring);
>  	for (i = 0; i < size; i++) {
>  		if ((page[i] = cas_page_alloc(cp, GFP_KERNEL)) == NULL)
> -			return -1;
> +			return -ENOMEM;
>  	}
>  	return 0;
>  }

static int cas_alloc_rxds(struct cas *cp)
{
	int i;

	for (i = 0; i < N_RX_DESC_RINGS; i++) {
		if (cas_alloc_rx_desc(cp, i) < 0) {
	       		cas_free_rxds(cp);
			return -1;
		}
	}
	return 0;
}

Again, your change is correct, but in the end the value is not used.
And if you fix it at the cas_alloc_rxds level, you also need a fix at
the next level up:

	err = -ENOMEM;
	if (cas_tx_tiny_alloc(cp) < 0)
		goto err_unlock;

	/* alloc rx descriptors */
	if (cas_alloc_rxds(cp) < 0)
		goto err_tx_tiny;

again, the return value is discarded.

       Andrew

WARNING: multiple messages have this Message-ID (diff)
From: Andrew Lunn <andrew@lunn.ch>
To: Allen Pais <allen.lkml@gmail.com>
Cc: linux-fbdev@vger.kernel.org, linux-scsi@vger.kernel.org,
	nouveau@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	dri-devel@lists.freedesktop.org, target-devel@vger.kernel.org,
	linux-crypto@vger.kernel.org, netdev@vger.kernel.org,
	linux-btrfs@vger.kernel.org, MPT-FusionLinux.pdl@broadcom.com,
	megaraidlinux.pdl@broadcom.com
Subject: Re: [PATCH 06/10] drivers:ethernet: return -ENOMEM on allocation failure.
Date: Wed, 13 Sep 2017 12:16:28 +0000	[thread overview]
Message-ID: <20170913121628.GB11820@lunn.ch> (raw)
In-Reply-To: <1505287939-14106-6-git-send-email-allen.lkml@gmail.com>

On Wed, Sep 13, 2017 at 01:02:15PM +0530, Allen Pais wrote:
> Signed-off-by: Allen Pais <allen.lkml@gmail.com>
> ---
>  drivers/net/ethernet/sun/cassini.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/sun/cassini.c b/drivers/net/ethernet/sun/cassini.c
> index 382993c..fc0ea3a 100644
> --- a/drivers/net/ethernet/sun/cassini.c
> +++ b/drivers/net/ethernet/sun/cassini.c
> @@ -3984,7 +3984,7 @@ static inline int cas_alloc_rx_desc(struct cas *cp, int ring)
>  	size = RX_DESC_RINGN_SIZE(ring);
>  	for (i = 0; i < size; i++) {
>  		if ((page[i] = cas_page_alloc(cp, GFP_KERNEL)) = NULL)
> -			return -1;
> +			return -ENOMEM;
>  	}
>  	return 0;
>  }

static int cas_alloc_rxds(struct cas *cp)
{
	int i;

	for (i = 0; i < N_RX_DESC_RINGS; i++) {
		if (cas_alloc_rx_desc(cp, i) < 0) {
	       		cas_free_rxds(cp);
			return -1;
		}
	}
	return 0;
}

Again, your change is correct, but in the end the value is not used.
And if you fix it at the cas_alloc_rxds level, you also need a fix at
the next level up:

	err = -ENOMEM;
	if (cas_tx_tiny_alloc(cp) < 0)
		goto err_unlock;

	/* alloc rx descriptors */
	if (cas_alloc_rxds(cp) < 0)
		goto err_tx_tiny;

again, the return value is discarded.

       Andrew

  reply	other threads:[~2017-09-13 12:16 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-13  7:32 [PATCH 01/10] arch:powerpc: return -ENOMEM on failed allocation Allen Pais
2017-09-13  7:44 ` Allen Pais
2017-09-13  7:32 ` [PATCH 02/10] drivers:crypto: return -ENOMEM on allocation failure Allen Pais
2017-09-13  7:44   ` Allen Pais
2017-10-07  4:21   ` Herbert Xu
2017-10-07  4:21     ` Herbert Xu
2017-10-07  4:21     ` Herbert Xu
2017-09-13  7:32 ` [PATCH 03/10] driver:gpu: " Allen Pais
2017-09-13  7:44   ` Allen Pais
2017-10-12 17:55   ` [Nouveau] " Daniel Vetter
2017-10-12 17:55     ` Daniel Vetter
2017-10-12 17:55     ` Daniel Vetter
2017-09-13  7:32 ` [PATCH 04/10] drivers:mpt: " Allen Pais
2017-09-13  7:44   ` Allen Pais
2017-09-13  7:32 ` [PATCH 05/10] drivers:net: " Allen Pais
2017-09-13  7:44   ` Allen Pais
2017-09-13 12:09   ` Andrew Lunn
2017-09-13 12:09     ` Andrew Lunn
2017-09-13 13:05     ` Allen
2017-09-13 13:17       ` Allen
2017-09-20  7:11     ` Allen
2017-09-13  7:32 ` [PATCH 06/10] drivers:ethernet: " Allen Pais
2017-09-13  7:44   ` Allen Pais
2017-09-13 12:16   ` Andrew Lunn [this message]
2017-09-13 12:16     ` Andrew Lunn
2017-09-13 12:16     ` Andrew Lunn
2017-09-13 13:04     ` Allen
2017-09-13 13:16       ` Allen
2017-09-20  6:50     ` Allen
2017-09-13 16:20   ` David Miller
2017-09-13 16:20     ` David Miller
2017-09-13  7:32 ` [PATCH 07/10] driver:megaraid: " Allen Pais
2017-09-13  7:44   ` Allen Pais
2017-09-13  7:32 ` [PATCH 08/10] driver:cxgbit: return -NOMEM " Allen Pais
2017-09-13  7:44   ` Allen Pais
2017-09-13  7:32 ` [PATCH 09/10] driver:video: return -ENOMEM " Allen Pais
2017-09-13  7:44   ` Allen Pais
     [not found]   ` <CGME20171012152104epcas2p1eb369268eae1872368d15bdc729de041@epcas2p1.samsung.com>
2017-10-12 15:21     ` [09/10] " Bartlomiej Zolnierkiewicz
2017-10-12 15:21       ` Bartlomiej Zolnierkiewicz
2017-09-13  7:32 ` [PATCH 10/10] fs:btrfs: " Allen Pais
2017-09-13  7:44   ` Allen Pais
2017-09-13 15:13   ` David Sterba
2017-09-13 15:13     ` David Sterba
2017-09-13 14:53 ` [PATCH 01/10] arch:powerpc: return -ENOMEM on failed allocation Joe Perches
2017-09-13 14:53   ` Joe Perches
2017-09-14  4:43   ` Allen
2017-09-14  4:55     ` Allen

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=20170913121628.GB11820@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=MPT-FusionLinux.pdl@broadcom.com \
    --cc=allen.lkml@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=megaraidlinux.pdl@broadcom.com \
    --cc=netdev@vger.kernel.org \
    --cc=nouveau@lists.freedesktop.org \
    --cc=target-devel@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.