Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3540848pxj; Mon, 24 May 2021 09:00:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzve4KGp1ptr+Wae5ax8n2FAVQMb5562F1RHU48FD+Y36HCeRobTJok8/KFi0Jnk1oGcEi2 X-Received: by 2002:a5d:884e:: with SMTP id t14mr14461167ios.111.1621872020447; Mon, 24 May 2021 09:00:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621872020; cv=none; d=google.com; s=arc-20160816; b=qoup8VlfFM+I47h4HdJaDBEqJAqsipJ9g5Em5QnKMKrkD3BPuqlIHliR8hweDR34P7 FDMN5GbjU6smioSfdRRv6JqBh57nfDbpb0G2eTPHhTbnw7kkGmw2cRU2hHXt2R3CXuBy O4AxaHYwA0FBLr9HMAuGS5MK62KccAHRQt0MERoBXHmlCVI2YxucJGn3C3vWNgqNUDQO vzSWrvM5tBlIFrp6K+BtxDsYHJ2oEHfUEt3SegQOulJtRKnFP2UJ5+w+scawrNEPmdpg 7LLBaT/BgEOEPw8G8wLIoc25/7uxGoSgcQ6UIXhP5YvVbGwYfm57qIXUAAPgn0yiXN3z A9Zg== 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=ZTeCqK021fLH/ygTC+tsddHUu40bshJRlo03WKoJ/J6YCr1pyAggQMnDaxocRUlk6K JZKSZ/B8TBjFogZztlkmYROI8NqX8mod14zSJP7wNFRIQOjkCszbkuc7nOu8Rz2AKUwd 3QLcsbro5Ierfz115vmPtVtaquB2T+3SP5Da2SwZm6HX7DqQlsUvKWdal/alCuY+hu+d SOA7pc/ujeRErEDcT0AiBVCJNm7UxyfXhmffSP46lOrT8flQ5Ausiw3XhhVCQ1pTwtl/ cGDZ95rys1ZlvMK9vcp0g1ySHjHQm25iz5S3mdZSdKIxwImcHBrOINiPO30zWyBPTgdD umow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DbJUyySs; 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 p8si13809832ils.114.2021.05.24.09.00.05; Mon, 24 May 2021 09:00: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=DbJUyySs; 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 S235999AbhEXQBB (ORCPT + 99 others); Mon, 24 May 2021 12:01:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:38928 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235445AbhEXPzI (ORCPT ); Mon, 24 May 2021 11:55:08 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 764FA6192D; Mon, 24 May 2021 15:41:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621870885; bh=o+GyRoW6tVYJFg5ygPEDk8ouNulvrjmiE7rvNFCY9mc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DbJUyySsHFY4XyHDWanm7YN8EUYSX2n3DIh3U3y+rTr3wE6GHyIg+dzuCAP6krhrl /gP0klsuQxa1zOgV0bn2h0+xsBDAmy6CCOh8eiJPoqVw4oHme6+3VSzVjDZqdvhTay r47n5KMCBokOzboG63sjmPlmZ/TsS8IPJbOzsk88= 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.10 052/104] rapidio: handle create_workqueue() failure Date: Mon, 24 May 2021 17:25:47 +0200 Message-Id: <20210524152334.568084523@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152332.844251980@linuxfoundation.org> References: <20210524152332.844251980@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;