From patchwork Mon Jun 1 17:52:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 225062 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D60CC433E0 for ; Mon, 1 Jun 2020 18:12:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 132412068D for ; Mon, 1 Jun 2020 18:12:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591035139; bh=N/W/8g3PtuuoC034RzeB9JObwXv0drfERwy505VPvqE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=oAfFrNgP+RGV5d7hr3Aq3HWREdmOiSVolCOHk2dJ4y8z0gomPaiVpXT8bb8sii+je v8+VqpNLl07utMRndU81ZrgnmHlb/axlCr2Vo94aNWdf2sM1eGN9mKg5ovbA9K+0lw vQf1FNSnUsjiNdUYkTFUofpiyO/E2siRjzOXCTP0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731202AbgFASMS (ORCPT ); Mon, 1 Jun 2020 14:12:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:59616 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731173AbgFASMR (ORCPT ); Mon, 1 Jun 2020 14:12:17 -0400 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 3D4FF2065C; Mon, 1 Jun 2020 18:12:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591035136; bh=N/W/8g3PtuuoC034RzeB9JObwXv0drfERwy505VPvqE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mTWJdtlm2eCK/lxKc1L+EXQHmxxLlk2pOOjxeKFOEI29fISg+EDlvJlWmtZsOKDje sDQGYH2jJRQQK6Clu1zF2FMXscYLJ2mukZ1BxY0uVBenIYlGRMQJvU+8LUwjHhoDn+ ywM6PeJyXgoiASIElLUCvKQRco0N8fNcOfUGuZD8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Moshe Shemesh , Tariq Toukan , Saeed Mahameed Subject: [PATCH 5.6 025/177] net/mlx5: Fix memory leak in mlx5_events_init Date: Mon, 1 Jun 2020 19:52:43 +0200 Message-Id: <20200601174050.884588189@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200601174048.468952319@linuxfoundation.org> References: <20200601174048.468952319@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Moshe Shemesh [ Upstream commit df14ad1eccb04a4a28c90389214dbacab085b244 ] Fix memory leak in mlx5_events_init(), in case create_single_thread_workqueue() fails, events struct should be freed. Fixes: 5d3c537f9070 ("net/mlx5: Handle event of power detection in the PCIE slot") Signed-off-by: Moshe Shemesh Reviewed-by: Tariq Toukan Signed-off-by: Saeed Mahameed Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/mellanox/mlx5/core/events.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/net/ethernet/mellanox/mlx5/core/events.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/events.c @@ -346,8 +346,10 @@ int mlx5_events_init(struct mlx5_core_de events->dev = dev; dev->priv.events = events; events->wq = create_singlethread_workqueue("mlx5_events"); - if (!events->wq) + if (!events->wq) { + kfree(events); return -ENOMEM; + } INIT_WORK(&events->pcie_core_work, mlx5_pcie_event); return 0;