Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp2685042pxy; Mon, 3 May 2021 05:56:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWHzB7BB9sjNX/FZCeFmMIl5i576xDa2Let5R+pUVmMDVxaZQqWVa/wMi6445QdU9zz/82 X-Received: by 2002:a63:e706:: with SMTP id b6mr18232675pgi.302.1620046576774; Mon, 03 May 2021 05:56:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620046576; cv=none; d=google.com; s=arc-20160816; b=D5NruV0gN2huoLSBeXCwmQBvTMASYtO579F7PsMSDQqZuu0/IYqD8U6yVuPnOG7edr ediYc3ho9TtzJE/JQo/4QdSJNMq7J7BJaPMcXUXPCb8lthiRohPKApSBsZlzvzVqwI2Y bYaJ27a3exDij63Rp0xrTL2JUKcWBmz+wvYDfzSnsnEBT4cbf8Xbvgb3NGKd8SqWBl8Q YEhRR3yrhKIeL9J8H81PTwmMlD1KITjL+B/2reiaR2AKDZfzv9QrVQFo/dnQAj5WrRIM BHZopbWBwDid+/dCFg2E1wUePOb4clwyZIqWenrS8hkUJqm9XZV4yEf+CtnFwkkx81Je Rd3Q== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=bW7/ym5UL4jVHgrlqH4r2d+Bzaq4wQnKAIufBfPwQoU=; b=KE2Fjf2hQ4eoUqx5v/Q/fpG1Y0IOo0NaNgJNa71hY1bLwUI0cnYsEucgUXSPiO5L3j xwqpaS1Hq8myW2Gpj0vCBKr/Y8YJ+fzqanyMuOHhDggSCLuYUD4DQMcQqnYK3MFIdual v4dIT6L7IzPRJLlUHjQej2cjrLsNNz0oLVxDNMbC9EGFKcfVyp1uXM0OcNBiWZfBwszr ke7dEHN9UJ0Qg7gI1fxG5VIcfQ4soDbTjZeunJV7XQmoVgPzF78slC9GvgP6zJMvn/tN KR9D0ZfIeRoetCMvui32S+wY5liCA8IYXqhktyp84/NvoItFfVdJFNwzzEJ8N0LST3zO xpzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JniMMyfD; 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 k5si250047pja.159.2021.05.03.05.56.04; Mon, 03 May 2021 05:56:16 -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=JniMMyfD; 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 S233640AbhECMAL (ORCPT + 99 others); Mon, 3 May 2021 08:00:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:34046 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233353AbhECMAD (ORCPT ); Mon, 3 May 2021 08:00:03 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7D6236121D; Mon, 3 May 2021 11:59:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620043150; bh=mZZgUJN7S8ehEpZrjCrMgLzaVUg61xObJtcf+RMK1Ro=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JniMMyfDZ8RMeaCf3Jo7dEWGwXx5Ao28/ngzDM+IYzS9aob+FtrkB2mrEKXxrmnK7 n0hU9UtXqBSkpk66rUHhLDuRXgCzW+M24fAVfU5Nl/zNAvya5Rvb4RK37qXySx0s95 vJInkKri0MM9IhKrPdL1W7OmZlCZsFdbsPdcVe7k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Anirudh Rayabharam , Ursula Braun , "David S . Miller" , Greg Kroah-Hartman Subject: [PATCH 17/69] net/smc: properly handle workqueue allocation failure Date: Mon, 3 May 2021 13:56:44 +0200 Message-Id: <20210503115736.2104747-18-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210503115736.2104747-1-gregkh@linuxfoundation.org> References: <20210503115736.2104747-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Anirudh Rayabharam 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 Signed-off-by: Greg Kroah-Hartman --- 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.31.1