mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Niels de Vos <niels.devos@wincor-nixdorf.com>
To: Eugene Teo <eugeneteo@kernel.org>
Cc: linux-kernel@vger.kernel.org, rolandd@cisco.com,
	sean.hefty@intel.com, hal.rosenstock@gmail.com
Subject: Re: [PATCH] IB: check for memory allocation failure
Date: Thu, 08 Jan 2009 15:05:58 +0100	[thread overview]
Message-ID: <49660846.2090200@wincor-nixdorf.com> (raw)
In-Reply-To: <20090108135549.GA9756@kernel.sg>

[-- Attachment #1: Type: text/plain, Size: 2191 bytes --]

Hi Eugene,

please see below.

Cheers,
Niels


Eugene Teo wrote:
> Fix error-path NULL deref in c2_register_device().
> 
> Signed-off-by: Eugene Teo <eugeneteo@kernel.org>
> ---
>  drivers/infiniband/hw/amso1100/c2_provider.c |   14 +++++++++-----
>  1 file changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/amso1100/c2_provider.c b/drivers/infiniband/hw/amso1100/c2_provider.c
> index 5119d65..8cede6c 100644
> --- a/drivers/infiniband/hw/amso1100/c2_provider.c
> +++ b/drivers/infiniband/hw/amso1100/c2_provider.c
> @@ -780,11 +780,11 @@ int c2_register_device(struct c2_dev *dev)
>  	/* Register pseudo network device */
>  	dev->pseudo_netdev = c2_pseudo_netdev_init(dev);
>  	if (!dev->pseudo_netdev)
> -		goto out3;
> +		goto out4;
>
>  	ret = register_netdev(dev->pseudo_netdev);
>  	if (ret)
> -		goto out2;
> +		goto out3;
>  
>  	pr_debug("%s:%u\n", __func__, __LINE__);
>  	strlcpy(dev->ibdev.name, "amso%d", IB_DEVICE_NAME_MAX);
> @@ -851,6 +851,8 @@ int c2_register_device(struct c2_dev *dev)
>  	dev->ibdev.post_recv = c2_post_receive;
>  
>  	dev->ibdev.iwcm = kmalloc(sizeof(*dev->ibdev.iwcm), GFP_KERNEL);
> +	if (!dev->ibdev.iwcm)
> +		goto out2;

Is it not needed to set 'ret = -ENOMEM'?


>  	dev->ibdev.iwcm->add_ref = c2_add_ref;
>  	dev->ibdev.iwcm->rem_ref = c2_rem_ref;
>  	dev->ibdev.iwcm->get_qp = c2_get_qp;
> @@ -870,15 +872,17 @@ int c2_register_device(struct c2_dev *dev)
>  		if (ret)
>  			goto out0;
>  	}
> -	goto out3;
> +	goto out4;
>  
>  out0:
>  	ib_unregister_device(&dev->ibdev);
>  out1:
> -	unregister_netdev(dev->pseudo_netdev);
> +	kfree(dev->ibdev.iwcm);
>  out2:
> -	free_netdev(dev->pseudo_netdev);
> +	unregister_netdev(dev->pseudo_netdev);
>  out3:
> +	free_netdev(dev->pseudo_netdev);
> +out4:
>  	pr_debug("%s:%u ret=%d\n", __func__, __LINE__, ret);
>  	return ret;
>  }
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

      reply	other threads:[~2009-01-08 14:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-08 13:56 Eugene Teo
2009-01-08 14:05 ` Niels de Vos [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=49660846.2090200@wincor-nixdorf.com \
    --to=niels.devos@wincor-nixdorf.com \
    --cc=eugeneteo@kernel.org \
    --cc=hal.rosenstock@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rolandd@cisco.com \
    --cc=sean.hefty@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

all inboxes | Powered by JetHome®