Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2743005pxj; Mon, 31 May 2021 09:36:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwfJfpcoZS1KFuenUFxB8R7KtFbNE72QLuznAVVY6O7O/R/a6XDMW4U/CtY6r38j4sHcBQ X-Received: by 2002:a17:906:3598:: with SMTP id o24mr10314568ejb.551.1622479006636; Mon, 31 May 2021 09:36:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622479006; cv=none; d=google.com; s=arc-20160816; b=rZZXFNnqYcs7envGANbXqN15rSQXXPnLchJJarFgz+z4vom2hPk30sIXrhspzsLHjW 83ic35Qb+g+yJwDL8AAEncqOHUXpUR3caqxjSa8pKoM+MuQZTF6geU4Q66s0klJ9ZEak ssGzfpC7Sz2wXCTSwdkWYeFscibe78wFs6Zeny17VglJ5dMiPLGHHbWQg3T2dEWwZcC1 Z4rv79mftCDSMZVATFzIDtavuXhAGPYgj8mwV/qHfOlxUU1VVBgTJADgflWl5KtRbOOF 4sd3Xria1Hs81JrWfI6xT/DLp/frNGqYnlKSGFJyEVbkLmLd0VMYchoBMH9GCTwkATkt vKwg== 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=1iB7qkzzeRKhqXSqdgqFFnTk3NSP/NzK9GOlU733ots=; b=tlxY06avVhvg+Zda3jjWEk6e413YK9bIj3gvWAi7dOohqetseyrfoglWjhHJ3yGLyz tg+UILfLaDr2jUKyLGV9701tUjqA3rNQIHeN52OirPKh44CWOjDH8EWiOwgdYvVoWhXe jDWZRw2LWkox6D7OxEUkz4eLLwZ1jWihyWZh3TGcbQSKSvykc8aQQeyBM1+Q7yjD5jjg d0xeHOkyQlSgvdvLF2l6NrEOy5orxlxM+ysn97TyuYyQMsFcg9kArsdIIFZE2VG2XUeF uez+Xc6h5r/YNuKepUmcDS2nuxkW/i2mCF+YxwI9h4x+nkKqahZeB2+CEpf1+fd1PHGZ XwnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=avhyamjI; 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 ar9si16730660ejc.663.2021.05.31.09.36.23; Mon, 31 May 2021 09:36:46 -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=avhyamjI; 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 S233773AbhEaQdx (ORCPT + 99 others); Mon, 31 May 2021 12:33:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:40788 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233893AbhEaOrn (ORCPT ); Mon, 31 May 2021 10:47:43 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6FA5B61926; Mon, 31 May 2021 13:56:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622469384; bh=Z+xxVOW3tkq0jglHKtvwqtWgs4bHwq0PWj8XRzQNyW8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=avhyamjIndi0epqvHa5Tfo9QlbwgPgkk1pghkcCaPsvkXpUChpphbFWOwWYIvxX2c 6lagmyiPCBr+ur6IyrsXL44aw/1KylHRH1jYeWID+hcQ8RRwUji2nEZMjB8rS0ua/t 89lRc0BeWMF0DPpnxDAWSHSv3kZ7tuZ6zdR2oOic= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ursula Braun , "David S. Miller" , Anirudh Rayabharam , Sasha Levin Subject: [PATCH 5.12 170/296] net/smc: properly handle workqueue allocation failure Date: Mon, 31 May 2021 15:13:45 +0200 Message-Id: <20210531130709.588259921@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130703.762129381@linuxfoundation.org> References: <20210531130703.762129381@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 [ Upstream commit bbeb18f27a44ce6adb00d2316968bc59dc640b9b ] In smcd_alloc_dev(), if alloc_ordered_workqueue() fails, properly catch it, clean up and return NULL to let the caller know there was a failure. Move the call to alloc_ordered_workqueue higher in the function in order to abort earlier without needing to unwind the call to device_initialize(). Cc: Ursula Braun Cc: David S. Miller Signed-off-by: Anirudh Rayabharam Link: https://lore.kernel.org/r/20210503115736.2104747-18-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- net/smc/smc_ism.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/net/smc/smc_ism.c b/net/smc/smc_ism.c index 6558cf7643a7..94b31f2551bc 100644 --- a/net/smc/smc_ism.c +++ b/net/smc/smc_ism.c @@ -402,6 +402,14 @@ struct smcd_dev *smcd_alloc_dev(struct device *parent, const char *name, return NULL; } + smcd->event_wq = alloc_ordered_workqueue("ism_evt_wq-%s)", + WQ_MEM_RECLAIM, name); + if (!smcd->event_wq) { + kfree(smcd->conn); + kfree(smcd); + return NULL; + } + smcd->dev.parent = parent; smcd->dev.release = smcd_release; device_initialize(&smcd->dev); @@ -415,8 +423,6 @@ struct smcd_dev *smcd_alloc_dev(struct device *parent, const char *name, INIT_LIST_HEAD(&smcd->vlan); INIT_LIST_HEAD(&smcd->lgr_list); init_waitqueue_head(&smcd->lgrs_deleted); - smcd->event_wq = alloc_ordered_workqueue("ism_evt_wq-%s)", - WQ_MEM_RECLAIM, name); return smcd; } EXPORT_SYMBOL_GPL(smcd_alloc_dev); -- 2.30.2