Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp6551913ybx; Mon, 11 Nov 2019 10:49:40 -0800 (PST) X-Google-Smtp-Source: APXvYqwTtcaJKhxaqfGQc5nAtp8MDrroRSYo8woEAfpN5IOe1Z0ad23NzaeOPa3HPm9zNdCjqdMs X-Received: by 2002:a05:6402:134f:: with SMTP id y15mr28756431edw.147.1573498180042; Mon, 11 Nov 2019 10:49:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573498180; cv=none; d=google.com; s=arc-20160816; b=x+ktt4LWzHiVUxGmn1TbUiJT1ebpRp8Rxm6vMH3L5QsgXivK8PBPuoIeEpLObd4uqC /BHTs5BvlCU9oTyfxuUohQvNLUdl4zd8EQSDxNyGB3jqQYae21TDW6B7A4+L3CNk1pQQ 5HFTkgbg4UZRu5k5C6x6/feo1LtHpwR8WBmwKZmrow6LgVmAlukIzH/EOULG8sD9C2HM DURFsGBHVuKz+TN0bLMrR2dIR74jECJQFIbVHk8pu2fxXFvJTc1xxxXIbjDV47iW7I+Y rIS68ZftyhjzquN8QhXNNrLUz5dWPXHEvKZPNsIW2FK9IXRlN2Q3GvwVt8wwpMBNE/2R 1BJg== 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=+fBc2aLcXj8Ff1TRdwXufsvD4ZJ1czO65X+zYmrDVmI=; b=abPGOEQMUIY0gI4ioM7y+Pagw/GyXW+6CPjbdnTY4SOUwo86h/vunUgK1BL49nVrrl j5vQMOF/WT81GhZVOBSeBR17vyZIOEEwFig+m4ifk0j3v/iUsD/6w6kc0jp4Xk87b6wE Cwy996TYcnFO6cnJR2FiEpw9ItS8IPG9WglrlOU+quPAVc7DP7sQyslFzPrFTH8+axat bU2NTjxPlApI6wjit7ES1DFUlLWTCa+dGtftYmWduZY3CeV9ez4FIyjUnMFjYXySVNXY C+G4chPuWKNHd3ZGBndnKJr7+UUc/tNjehwmj6XAknvHa4N15gWBpPC/Y1GZe+p2PA0L O8Qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mstTC3iA; 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 r7si10550385edm.224.2019.11.11.10.49.15; Mon, 11 Nov 2019 10:49:40 -0800 (PST) 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=mstTC3iA; 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 S1729925AbfKKSpw (ORCPT + 99 others); Mon, 11 Nov 2019 13:45:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:38094 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729246AbfKKSpv (ORCPT ); Mon, 11 Nov 2019 13:45:51 -0500 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 DA12920674; Mon, 11 Nov 2019 18:45:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573497950; bh=+Vpmt56nQU9q+fWQ80iwQhJ7ao0djqDkThe4tFknWvA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mstTC3iAPl7ThYOghBhUf56aAyPnNnpmZ3fl5YFYgwo+71xObBYGqTn5lolJwf6IR inBWdTN1rtHrgRz1Jyt91k5aVAmjxArpITdYHgKb1cV3jqWTHCCeTkul6WTD3QbNfO ZJgIhvjng1Nz1R6pBGSe/mmT+BXY5IWkVDcCRpXU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "David S. Miller" , Nicolas Waisman , Will Deacon , Sasha Levin Subject: [PATCH 4.19 105/125] fjes: Handle workqueue allocation failure Date: Mon, 11 Nov 2019 19:29:04 +0100 Message-Id: <20191111181453.950179740@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191111181438.945353076@linuxfoundation.org> References: <20191111181438.945353076@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 From: Will Deacon [ Upstream commit 85ac30fa2e24f628e9f4f9344460f4015d33fd7d ] In the highly unlikely event that we fail to allocate either of the "/txrx" or "/control" workqueues, we should bail cleanly rather than blindly march on with NULL queue pointer(s) installed in the 'fjes_adapter' instance. Cc: "David S. Miller" Reported-by: Nicolas Waisman Link: https://lore.kernel.org/lkml/CADJ_3a8WFrs5NouXNqS5WYe7rebFP+_A5CheeqAyD_p7DFJJcg@mail.gmail.com/ Signed-off-by: Will Deacon Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/fjes/fjes_main.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/net/fjes/fjes_main.c b/drivers/net/fjes/fjes_main.c index d3eae12390457..61a9843346ad7 100644 --- a/drivers/net/fjes/fjes_main.c +++ b/drivers/net/fjes/fjes_main.c @@ -1252,8 +1252,17 @@ static int fjes_probe(struct platform_device *plat_dev) adapter->open_guard = false; adapter->txrx_wq = alloc_workqueue(DRV_NAME "/txrx", WQ_MEM_RECLAIM, 0); + if (unlikely(!adapter->txrx_wq)) { + err = -ENOMEM; + goto err_free_netdev; + } + adapter->control_wq = alloc_workqueue(DRV_NAME "/control", WQ_MEM_RECLAIM, 0); + if (unlikely(!adapter->control_wq)) { + err = -ENOMEM; + goto err_free_txrx_wq; + } INIT_WORK(&adapter->tx_stall_task, fjes_tx_stall_task); INIT_WORK(&adapter->raise_intr_rxdata_task, @@ -1270,7 +1279,7 @@ static int fjes_probe(struct platform_device *plat_dev) hw->hw_res.irq = platform_get_irq(plat_dev, 0); err = fjes_hw_init(&adapter->hw); if (err) - goto err_free_netdev; + goto err_free_control_wq; /* setup MAC address (02:00:00:00:00:[epid])*/ netdev->dev_addr[0] = 2; @@ -1292,6 +1301,10 @@ static int fjes_probe(struct platform_device *plat_dev) err_hw_exit: fjes_hw_exit(&adapter->hw); +err_free_control_wq: + destroy_workqueue(adapter->control_wq); +err_free_txrx_wq: + destroy_workqueue(adapter->txrx_wq); err_free_netdev: free_netdev(netdev); err_out: -- 2.20.1