linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kangjie Lu <kjlu@umn.edu>
To: kjlu@umn.edu
Cc: pakki001@umn.edu, Wolfgang Grandegger <wg@grandegger.com>,
	Marc Kleine-Budde <mkl@pengutronix.de>,
	"David S. Miller" <davem@davemloft.net>,
	Wei Liu <wei.liu2@citrix.com>, Joe Perches <joe@perches.com>,
	linux-can@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net: spi: fix a potential NULL pointer dereference
Date: Fri, 22 Mar 2019 22:10:36 -0500	[thread overview]
Message-ID: <5465C285-BE0C-4FEF-B732-18B5A8F44C8D@umn.edu> (raw)
In-Reply-To: <20190310075735.3392-1-kjlu@umn.edu>



> On Mar 10, 2019, at 1:57 AM, Kangjie Lu <kjlu@umn.edu> wrote:
> 
> In case alloc_workqueue fails to allocate the work queue and
> returns NULL, the fix releases the resources and returns
> -ENOMEM.
> 
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> ---
> drivers/net/can/spi/mcp251x.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/net/can/spi/mcp251x.c b/drivers/net/can/spi/mcp251x.c
> index e90817608645..2737b9a20dfe 100644
> --- a/drivers/net/can/spi/mcp251x.c
> +++ b/drivers/net/can/spi/mcp251x.c
> @@ -962,6 +962,14 @@ static int mcp251x_open(struct net_device *net)
> 
> 	priv->wq = alloc_workqueue("mcp251x_wq", WQ_FREEZABLE | WQ_MEM_RECLAIM,
> 				   0);
> +	if (unlikely(!priv->wq)) {
> +		dev_err(&spi->dev, "failed to allocate work queue\n");
> +		mcp251x_power_enable(priv->transceiver, 0);
> +		close_candev(net);
> +		ret = -ENOMEM;
> +		goto open_unlock;
> +	}
> +

Can someone review this patch?


> 	INIT_WORK(&priv->tx_work, mcp251x_tx_work_handler);
> 	INIT_WORK(&priv->restart_work, mcp251x_restart_work_handler);
> 
> -- 
> 2.17.1
> 


      reply	other threads:[~2019-03-23  3:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-10  7:57 [PATCH] net: spi: fix a potential NULL pointer dereference Kangjie Lu
2019-03-23  3:10 ` Kangjie Lu [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=5465C285-BE0C-4FEF-B732-18B5A8F44C8D@umn.edu \
    --to=kjlu@umn.edu \
    --cc=davem@davemloft.net \
    --cc=joe@perches.com \
    --cc=linux-can@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=netdev@vger.kernel.org \
    --cc=pakki001@umn.edu \
    --cc=wei.liu2@citrix.com \
    --cc=wg@grandegger.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;
as well as URLs for NNTP newsgroup(s).