Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp7077593ybi; Thu, 13 Jun 2019 09:11:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqyXWmvF2Co7DaaiQoTJUcH28luEC+FKi+0KbbGOAukNR6g1qJCQ0CiIxBySGFRYIzxy/PLa X-Received: by 2002:a17:90a:2190:: with SMTP id q16mr6196425pjc.23.1560442272856; Thu, 13 Jun 2019 09:11:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560442272; cv=none; d=google.com; s=arc-20160816; b=rNo76sKCiOKvyKNTKg712BtScgbGD0fhc5lLEI3aWCTUzN1u16jz4tfVG0o5mB+WmY 4Uc3dhtVDzCNqp4JwoDSF7r1WTtJaBPPjL18qz3LKT4KdaQf+h4T68sH7keVa5jz7h/j /VJETl3vvkqryQCTGezslfW5+wYUoN19LT8Yc/f35fDG6OjGuF/m4SsZDg6lkLhUyAQT 7SrbptIrrwnSP7ALOQ/S5y23Z+6nFRU0p5omGRPcKXde+XzgfmDnK05DLHTFDTSHE7CP 8uZnqsp0/8CNwi3jj7Vu5vtXeeQNUPGZmtfSMwWUAdZ3LPK633v9M4U7jLIdmYU80lpJ pCRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=biRmxi63AeYkKFv+1Yu99J9moI1KYWcGgKP31CaA5O0=; b=SaQwWmSkDrk8H8oaNfmc4v58MTnaGAGw1+89AK8vIPX6hyWWOW8Cq1Zgzr5/jmpTby mGxluXvzgdXUC+wEXuuevZ4QJ80uXukAM2r57pAzdXoKbuVG/Xe8DkFvpYUHWaXQ0smJ JHbB+TvMMUThsD7SOi4fRZC7eme3Yi4pry+kBtrHdtp2eBhfJ02hPSCqAk8FmyLGmajZ OHLzymCtzr1EwrnRPZ3uiT/d8oFKcpYgcN0Ob8Bc3uBcjG74WHBtu7Uy5a455Akca69I InsR0J5W30SoNT1TfQM7/iN5EY+oev8nFkDYqn4hHE+qzZ8a+0+dDMsBboSn0tXrCDr8 djOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SocppfwY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t5si134788pgv.164.2019.06.13.09.10.57; Thu, 13 Jun 2019 09:11:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SocppfwY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391382AbfFMQJU (ORCPT + 99 others); Thu, 13 Jun 2019 12:09:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:33358 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731262AbfFMIo1 (ORCPT ); Thu, 13 Jun 2019 04:44:27 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2EEF42173C; Thu, 13 Jun 2019 08:44:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560415466; bh=S5A7UTeQWhWBtP5fYLh/wg3KEQnbgwNH5S8HaOS8f1Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SocppfwY08nWCb0Rm+nR7PtrIxCw9SHT4YUxIkLB1GTqBn/bHKzdlYB/AmemaIBGQ HjwRfRfgvAPr27WLS2rzvPM4GB9WNMuju7kIaJHnqPSm2tHJf8ZaM9Q2MF+oSJdGIu bYK76tvZuAmMuKXjuiRUEn5wNBAV36gl54nqkIlM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kangjie Lu , Alexandre Bounine , Matt Porter , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 5.1 004/155] rapidio: fix a NULL pointer dereference when create_workqueue() fails Date: Thu, 13 Jun 2019 10:31:56 +0200 Message-Id: <20190613075652.964720344@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190613075652.691765927@linuxfoundation.org> References: <20190613075652.691765927@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 23015b22e47c5409620b1726a677d69e5cd032ba ] In case create_workqueue fails, the fix releases resources and returns -ENOMEM to avoid NULL pointer dereference. Signed-off-by: Kangjie Lu Acked-by: Alexandre Bounine Cc: Matt Porter Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- 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.20.1