Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2666041pxj; Mon, 31 May 2021 07:47:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzyp06jS+ToNdSu5JX0tZyfGTOg3ZlKq6M/Pql6Yv+4MPejnZZyvD9G5dEURAI1dLeSrEmP X-Received: by 2002:a17:906:e10b:: with SMTP id gj11mr22804615ejb.202.1622472439848; Mon, 31 May 2021 07:47:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622472439; cv=none; d=google.com; s=arc-20160816; b=rL18fhyQYx1g64LA+kH4rmWfdFXiEVdWCw6I42YYWN5R3jqC0JK4jBHWM9EHqzYojd F2vq8OWTfwPDEQPNQRUa/cSwMIgpqycuayzWaWcrvZf9mwFkig4oRlJKX5HNME7YbO3u l2uyhqXCR1dIW/RC7RRi/TSaYZ5F4YnH6L0jsOs+pL6y0KGSaxmQtbtfqr4q/dXkSYhA zMmiB9AoEjF4+NR7snPFyjRb/jHlCrbQ9yNnERGmF3R7jJRCzE3KBJ+L2npHwaScu7E2 b0p6disBEekJVcgLeSpYSMokaE6UhEjiTeeJQaBCY4fstjkVBdl0TJFwkYYgTYmr9WaY A19g== 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=vgWR94kSmzYKvleX2uh0IMfPiKmX/G3FPOMQQF/gGaY=; b=eivkX6+TNNFLbTht1Ky860/X1hqOKzXV2+/Vmgk6ux4fu5x2CP7JZ+HtegthR+xuq4 6SdOTqlozilHaCwF5A9jwUL+GP+jAPkD2r0pXYqfE9loCPy4g1NgLPtBg5SMOu0HsQn1 SW71oUSJJ7uU+6gEBn67vihbH1ieLB1CwIGSy/FqQaHhpoBnLMZshltnJl0OnvZRnG2G j6KKtpaFMciC0Jp5+JtDvnx5Vy4k/1uAAdF0ifvMGeCGOrSuuTbNZtG0QFKF+DPoVdK4 Dx4YG0k7vMMITHtfSjL0NFrvLjM79PgOEbkwWrar++2fTCICI8hxq3ng3eNYJV8MIO6m VgrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="c0O7fS/8"; 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 c16si14150657edw.162.2021.05.31.07.46.55; Mon, 31 May 2021 07:47:19 -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="c0O7fS/8"; 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 S232259AbhEaOpP (ORCPT + 99 others); Mon, 31 May 2021 10:45:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:60040 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233099AbhEaN72 (ORCPT ); Mon, 31 May 2021 09:59:28 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 73ABB61938; Mon, 31 May 2021 13:36:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622468165; bh=pGVpLtSMWaOVVz49mJPWWGTE8xs1/cMgTS/V3efAK3E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c0O7fS/8EosUk9dt+2YSoS09ZYOI9lHgc0vUHpBHRiT7q5+Y9Ttvfy2D9KpP1v75K ysQns6SUwWSLBDaEBTFmQY8miUdKgMq3VJ4NY9jSqI7lIX/67+IHXbcVW6muH5yGOG TG7ha5Jom8tBUdJLPojsa1KXmP2z893F4eBddBFo= 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.10 140/252] net/smc: properly handle workqueue allocation failure Date: Mon, 31 May 2021 15:13:25 +0200 Message-Id: <20210531130702.773639175@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130657.971257589@linuxfoundation.org> References: <20210531130657.971257589@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 b4a9fe452470..024ca21392f7 100644 --- a/net/smc/smc_ism.c +++ b/net/smc/smc_ism.c @@ -304,6 +304,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); @@ -317,8 +325,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