Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3547823pxj; Mon, 24 May 2021 09:07:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJymAjAwqoI3k9g34WnZbGS7UOob0AY9RRmBWp6w5gOcCFuUAn/pDc6Nrh2Eal9Zymgwz2GW X-Received: by 2002:a05:6638:22b4:: with SMTP id z20mr24533906jas.128.1621872440843; Mon, 24 May 2021 09:07:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621872440; cv=none; d=google.com; s=arc-20160816; b=w4vRLrnZNY37RQ0ijq9fl3gLVX2NzMCQdBDUYxhmLnp5eMYk4G5IxgAMQfMjTkT/Tv S6zSckFsasSEYS76NYWFzoP6mwmoidVMlRnJt+R7xu3uJ+lY9X2V8sYeId9CY5dwXhKe 1ndlIunTfiQz0AAx5d0CSNgxxL4QIbMDEOFojAV0iuhfDhHZPbieBfMEY2cOMThJVrlm /8JIgeoAyMNXziPAf1u1vLz5t0zZglBCCU3MMRqhalf+sCdbEU3UTvRl3l09wkqfpQzG APUcRQZbGI0gBhNReBXpvyUj1vX5vET8r6PxoHwM9t4VZqRigRo9mMXQ5pPkEe/vEKOu fAVw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=7xw0F1yXmnNKABlpHuti9XIYelhSgYbTdo9enQdPKt8=; b=epjuyIDY2gkFfajCEHk93QwtWWS1PcNcvYTDPCHvOeoyTvUaNRz/QoQUDod2R17b2L AU4s7RUSnJJEYfdUi5CoTEF/HAB6amwiCehHCzzmCdYi0nmaMQNnNcIoX91OSw1V2Ke/ ER0DkOlmgkB9HNT+scO4uLF5gMRsfSc0GsTlkaMVTrb/n4BH9tr/qmBF9Q+53TJLNQxH BZsVmRTB2QqPMSEjRPNxyCOVZMvNpeMpdCB8AUEeFmEjFwfh4UxUs3nkIYX45/YAzhmK ucWiqEjGwlLWDM2Uid27t1oW6i8m43EU3za6BINjmXidRJSE9CEXYNOFs8gudNjbFXUD b0xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=L978vHcN; 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 v17si15420310jat.82.2021.05.24.09.07.08; Mon, 24 May 2021 09:07:20 -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=L978vHcN; 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 S234328AbhEXQIH (ORCPT + 99 others); Mon, 24 May 2021 12:08:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:42834 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235262AbhEXQAO (ORCPT ); Mon, 24 May 2021 12:00:14 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3951961463; Mon, 24 May 2021 15:45:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621871157; bh=o+GyRoW6tVYJFg5ygPEDk8ouNulvrjmiE7rvNFCY9mc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L978vHcN8qmTdpG7sGB4URTiEjGrasbOEJvI4sjbwgFD5Gzul+AzsCWGNVAi1KfbK Ji3uoCm5PlNiYFwXTZDT+WLLRg1L+gfTuO/boprws4omoLi295ukZHPO91uL9QQUc6 GuaeJ7M5ALVq35QoabVL92dKiK34WV9RFs+Q1vVY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexandre Bounine , Matt Porter , Andrew Morton , Linus Torvalds , Anirudh Rayabharam Subject: [PATCH 5.12 065/127] rapidio: handle create_workqueue() failure Date: Mon, 24 May 2021 17:26:22 +0200 Message-Id: <20210524152337.053607627@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152334.857620285@linuxfoundation.org> References: <20210524152334.857620285@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Anirudh Rayabharam commit 69ce3ae36dcb03cdf416b0862a45369ddbf50fdf upstream. 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 Link: https://lore.kernel.org/r/20210503115736.2104747-46-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman --- drivers/rapidio/rio_cm.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) --- a/drivers/rapidio/rio_cm.c +++ b/drivers/rapidio/rio_cm.c @@ -2127,6 +2127,14 @@ static int riocm_add_mport(struct device 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 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;