public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle•com>
To: Solarflare linux maintainers <linux-net-drivers@solarflare•com>
Cc: Ben Hutchings <bhutchings@solarflare•com>,
	netdev@vger•kernel.org, kernel-janitors@vger•kernel.org
Subject: [patch] sfc: check for allocation failure
Date: Mon, 2 Sep 2013 12:04:42 +0300	[thread overview]
Message-ID: <20130902082828.GA30037@elgon.mountain> (raw)

It upsets static analyzers when we don't check for allocation failure.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle•com>

diff --git a/drivers/net/ethernet/sfc/mtd.c b/drivers/net/ethernet/sfc/mtd.c
index ba6c87a..aac6897 100644
--- a/drivers/net/ethernet/sfc/mtd.c
+++ b/drivers/net/ethernet/sfc/mtd.c
@@ -384,6 +384,8 @@ static int falcon_mtd_probe(struct efx_nic *efx)
 
 	/* Allocate space for maximum number of partitions */
 	parts = kcalloc(2, sizeof(*parts), GFP_KERNEL);
+	if (!parts)
+		return -ENOMEM;
 	n_parts = 0;
 
 	spi = &nic_data->spi_flash;

             reply	other threads:[~2013-09-02  9:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-02  9:04 Dan Carpenter [this message]
2013-09-02 17:00 ` [patch] sfc: check for allocation failure Ben Hutchings
2013-09-04  2:49 ` David Miller
2013-09-04 14:41   ` Ben Hutchings
2013-09-04 15:07   ` [patch v2] " Dan Carpenter
2013-09-04 15:51     ` Ben Hutchings
2013-09-04 17:08     ` David Miller

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=20130902082828.GA30037@elgon.mountain \
    --to=dan.carpenter@oracle$(echo .)com \
    --cc=bhutchings@solarflare$(echo .)com \
    --cc=kernel-janitors@vger$(echo .)kernel.org \
    --cc=linux-net-drivers@solarflare$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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