All of lore.kernel.org
 help / color / mirror / Atom feed
From: <alex.bou9@gmail.com>
To: "'Kangjie Lu'" <kjlu@umn.edu>
Cc: <pakki001@umn.edu>, "'Matt Porter'" <mporter@kernel.crashing.org>,
	<linux-kernel@vger.kernel.org>, <akpm@linux-foundation.org>
Subject: RE: [PATCH] rapidio: fix a NULL pointer derefenrece when create_workqueue fails
Date: Mon, 18 Mar 2019 18:46:16 -0400	[thread overview]
Message-ID: <002201d4dddc$662129a0$32637ce0$@gmail.com> (raw)
In-Reply-To: <20190314061015.11291-1-kjlu@umn.edu>

Please correct spelling in the subject line: "dereference"

-----Original Message-----
From: Kangjie Lu <kjlu@umn.edu> 
Sent: Thursday, March 14, 2019 2:10 AM
To: kjlu@umn.edu
Cc: pakki001@umn.edu; Matt Porter <mporter@kernel.crashing.org>; Alexandre
Bounine <alex.bou9@gmail.com>; linux-kernel@vger.kernel.org
Subject: [PATCH] rapidio: fix a NULL pointer derefenrece when
create_workqueue fails

In case create_workqueue fails, the fix releases resources and
returns -ENOMEM to avoid NULL pointer dereference.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
 drivers/rapidio/rio_cm.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/rapidio/rio_cm.c b/drivers/rapidio/rio_cm.c
index cf45829585cb..b29fc258eeba 100644
--- a/drivers/rapidio/rio_cm.c
+++ b/drivers/rapidio/rio_cm.c
@@ -2147,6 +2147,14 @@ static int riocm_add_mport(struct device *dev,
 	mutex_init(&cm->rx_lock);
 	riocm_rx_fill(cm, RIOCM_RX_RING_SIZE);
 	cm->rx_wq = create_workqueue(DRV_NAME "/rxq");
+	if (!cm->rx_wq) {
+		riocm_error("failed to allocate IBMBOX_%d on %s",
+			    cmbox, mport->name);
+		rio_release_outb_mbox(mport, cmbox);
+		kfree(cm);
+		return -ENOMEM;
+	}
+
 	INIT_WORK(&cm->rx_work, rio_ibmsg_handler);
 
 	cm->tx_slot = 0;
-- 
2.17.1



      parent reply	other threads:[~2019-03-18 22:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-14  6:10 [PATCH] rapidio: fix a NULL pointer derefenrece when create_workqueue fails Kangjie Lu
2019-03-18 22:44 ` alex.bou9
2019-03-18 22:46 ` alex.bou9 [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='002201d4dddc$662129a0$32637ce0$@gmail.com' \
    --to=alex.bou9@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=kjlu@umn.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mporter@kernel.crashing.org \
    --cc=pakki001@umn.edu \
    /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.