Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp2696989pxy; Mon, 3 May 2021 06:09:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJznfwlQyy3R/imig5apr2Pi1O50NLQhsWvJ9yc56LEXRPfRgTUfRHm1xUjqtM/8wRi9ZksO X-Received: by 2002:a17:90b:4ad2:: with SMTP id mh18mr13699552pjb.148.1620047385969; Mon, 03 May 2021 06:09:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620047385; cv=none; d=google.com; s=arc-20160816; b=h0UeVOblM/3FIwL8h287gowPD1aIPz5EWkbinvvyNtCeZt+diTo05hPNRnrlZj5+ti AFY+nkp6j1Ee3sFRuAyyNWbJzM31MnEXdzBHqW+jYdcU1c3GgQNg4QtKTK8PRvC6eTpi wmgGM4LQPqkdFYcWL+bz/KGSX4rYqprGQyS6sBhMQ4SBsFbOSdQCDvgzx0NY+ADfbKay DDsmNCRUBH1mHV9RHfpvzzVOFT29I8bdIDaaTXcyIxjHqYRARMGHgIDQ8c692S+4vazJ IFyucQpahZVrqdPlFS8270pUYeJWuDkzTBnlVWligPNLRWjFCXHibeqZnbB1c+z+lLkG JMLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=wGtsWp13vBSbRk69GYFzkPB3V3fpjcBI80YU6FrJigY=; b=tPxYX1sHOOyQVMFSyzihWLvjIowbfGXzSaMsGKQ/9j7FX3TEDIx12IQeFlC4RHfCek 1CbwksAEJfnExXUFB2ZY6iaqceqeFbyokyfLaTka6bClm3dExBJLztDkwtW9UV1JaDkx xl3Mwi1fXN/cIyeDjLS4c+0WGRAvlHzBQyYlh7Jqqthz0hsfWcIK1GoBZjGp+BPwODgZ 290+WUMjcy/ITtQbjXV3bvs4TceBhPJyhfZVP8M8aEpiVqcPoepPOH8WGVnl3K9s6EHn KevACPwreMhiwKtRv0hFu/TvYYjRNmyoNT8dRYkmuindVVgRwQWCgIsizS+b2RR//TOV NG6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Z3GWTfGg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m13si3859175pjg.169.2021.05.03.06.09.12; Mon, 03 May 2021 06:09:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Z3GWTfGg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234028AbhECMCA (ORCPT + 99 others); Mon, 3 May 2021 08:02:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:35076 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233745AbhECMBP (ORCPT ); Mon, 3 May 2021 08:01:15 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3EFAC6137D; Mon, 3 May 2021 12:00:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620043217; bh=UrknPItb2AbCNnahCklZXeZnyfWxAgAVFiRoW5gXZLI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z3GWTfGg1P0eH0lCpTdcSp+wlKoCXjEFyyNu4cdJmAjhizo/gK3k7vzZGvAIOX0f7 a0MtSr+6YPfdiS+l3V4SBl4NPRhqrq+/in+ftRwOMM1TnKSIUXmecfUyptOMXgAgz9 y5JcbHVEbJGJLPRRZNpBSpKUT6aQpUrne62FT1Hc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Anirudh Rayabharam , Alexandre Bounine , Matt Porter , Andrew Morton , Linus Torvalds , stable , Greg Kroah-Hartman Subject: [PATCH 45/69] rapidio: handle create_workqueue() failure Date: Mon, 3 May 2021 13:57:12 +0200 Message-Id: <20210503115736.2104747-46-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210503115736.2104747-1-gregkh@linuxfoundation.org> References: <20210503115736.2104747-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Anirudh Rayabharam In case create_workqueue() fails, release all resources and return -ENOMEM to caller to avoid potential NULL pointer deref later. Move up the create_workequeue() call to return early and avoid unwinding the call to riocm_rx_fill(). Cc: Alexandre Bounine Cc: Matt Porter Cc: Andrew Morton Cc: Linus Torvalds Cc: stable Signed-off-by: Anirudh Rayabharam Signed-off-by: Greg Kroah-Hartman --- drivers/rapidio/rio_cm.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/rapidio/rio_cm.c b/drivers/rapidio/rio_cm.c index e6c16f04f2b4..db4c265287ae 100644 --- a/drivers/rapidio/rio_cm.c +++ b/drivers/rapidio/rio_cm.c @@ -2127,6 +2127,14 @@ static int riocm_add_mport(struct device *dev, return -ENODEV; } + cm->rx_wq = create_workqueue(DRV_NAME "/rxq"); + if (!cm->rx_wq) { + rio_release_inb_mbox(mport, cmbox); + rio_release_outb_mbox(mport, cmbox); + kfree(cm); + return -ENOMEM; + } + /* * Allocate and register inbound messaging buffers to be ready * to receive channel and system management requests @@ -2137,7 +2145,6 @@ static int riocm_add_mport(struct device *dev, cm->rx_slots = RIOCM_RX_RING_SIZE; mutex_init(&cm->rx_lock); riocm_rx_fill(cm, RIOCM_RX_RING_SIZE); - cm->rx_wq = create_workqueue(DRV_NAME "/rxq"); INIT_WORK(&cm->rx_work, rio_ibmsg_handler); cm->tx_slot = 0; -- 2.31.1