From patchwork Fri Nov 1 16:10:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 13859566 Received: from msa.smtpout.orange.fr (smtp-72.smtpout.orange.fr [80.12.242.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8E09E1C9DF9; Fri, 1 Nov 2024 16:12:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=80.12.242.72 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730477552; cv=none; b=oDAPnJHijvfj3vTRam4CuQcoe5aBQ81oy3wf9rV3woHaIO/AIEZNWVrXnFgYEZAOeARL2+gJPT1mzdoks9WbOe7gexUdffhVEDFjk48Jl43ffYzzLr5o2jrIIsRgprTy7mFo3WD2kF4U/YOSe/X06DLxFaN+vS0EgmtUaynDvng= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730477552; c=relaxed/simple; bh=ZdNtmwhmE4Sfo8kJ135RuDz63vpJTWBG4/q2lu1G/j0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=JOUFRXPl3ubmFxP/k1j+CshxvMhQrTI81Zuf0a9xIu+grpgPj4qU0Ui7T/wR5i19GwGL7pAuDd/SJfdWbEbFYES2o8FcDmYpmHQipy6lA3BX8DDX8jp1pfpljTTgfzWSLZBRIzIASuDNno1zmuKyP/IrbcQlIsuJx8U1rUcCfpc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wanadoo.fr; spf=pass smtp.mailfrom=wanadoo.fr; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b=cBKXzMSC; arc=none smtp.client-ip=80.12.242.72 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wanadoo.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wanadoo.fr Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b="cBKXzMSC" Received: from localhost.localdomain ([90.11.132.44]) by smtp.orange.fr with ESMTPA id 6uEutykeYoG5N6uEutJmjq; Fri, 01 Nov 2024 17:11:09 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1730477469; bh=wPMa1eF3oU3GrJIfNJgQ+4u1f7TLWzdyiv5eXacAmhE=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=cBKXzMSCK4fF5GcjbHlogDm9Vgf5AmTPoLOK28CixExetCFELJjqXx7ZSgvPwjj8E diKcDtPPgm56/knHDqMtiTSlkIxlbxjHfmWVLtK6JjOsL+BA/4W/XMVxTAAZFzAuqG jbwhbUV2VHT649/piuW1lAcSIcYWxVc35ngvFJXGc1LNwHSmgvVNZ/EjnukfPT2SyY +IC5Ux4CZIPv5x/POMhUc/Zlx7YbLu1kgRjYUNZNiuhiykkBL4iBJWeDm3oPIiLfU6 iXfNNvK08FJMIxgXfV9uwmEywhGPVIy/ZAL/bLswNMSfIVxDlD0yr8o3RzCh+Gvzpo s+W2HkCbZa5vw== X-ME-Helo: localhost.localdomain X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Fri, 01 Nov 2024 17:11:09 +0100 X-ME-IP: 90.11.132.44 From: Christophe JAILLET To: Selvin Xavier , Jason Gunthorpe , Leon Romanovsky , Kalesh AP Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-rdma@vger.kernel.org Subject: [PATCH v2 1/2] RDMA/bnxt_re: Fix some error handling paths in bnxt_re_probe() Date: Fri, 1 Nov 2024 17:10:56 +0100 Message-ID: <9e48ff955ae55fc39a9eb1eb590d374539eab5ba.1730477345.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.47.0 Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 If bnxt_re_add_device() fails, 'en_info' still needs to be freed, as already done in the .remove() function. The commit in Fixes incorrectly removed this call, certainly because it was expecting the .remove() function was called anyway. But if the probe fails, the remove function is not called. There is no need to call bnxt_re_remove() as it was done before, kfree() is enough. Fixes: a5e099e0c464 ("RDMA/bnxt_re: Fix an error path in bnxt_re_add_device") Signed-off-by: Christophe JAILLET --- Compile tested only Changes in v2: - use kfree() instead of calling bnxt_re_remove() v1: https://lore.kernel.org/all/580de136ad9b85b0d70709e912cfddd21b7e3f6f.1729930153.git.christophe.jaillet@wanadoo.fr/ --- drivers/infiniband/hw/bnxt_re/main.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/infiniband/hw/bnxt_re/main.c b/drivers/infiniband/hw/bnxt_re/main.c index 6715c96a3eee..465cec4a1bd4 100644 --- a/drivers/infiniband/hw/bnxt_re/main.c +++ b/drivers/infiniband/hw/bnxt_re/main.c @@ -2025,7 +2025,15 @@ static int bnxt_re_probe(struct auxiliary_device *adev, auxiliary_set_drvdata(adev, en_info); rc = bnxt_re_add_device(adev, BNXT_RE_COMPLETE_INIT); + if (rc) + goto err; + mutex_unlock(&bnxt_re_mutex); + return 0; + +err: mutex_unlock(&bnxt_re_mutex); + kfree(en_info); + return rc; } From patchwork Fri Nov 1 16:10:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 13859565 Received: from smtp.smtpout.orange.fr (smtp-19.smtpout.orange.fr [80.12.242.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 836802AE74; Fri, 1 Nov 2024 16:11:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=80.12.242.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730477482; cv=none; b=qX1ItH6+6s01HWC/CLqjpim5qrtYvSrvy3J3J5gcLXfCzL/s24laEAfct/KRQr7d9M+hVh14WDpbo6R+B1BI/DtccOZ4Al4/z9qwahzJeWtiXEf5DK673cvsvx8eSCGbazl9TC6ajMyqX6B7eMuDSVcSvkaqVdtDNLxRDGG8ZrI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730477482; c=relaxed/simple; bh=8fCDDzaSxAsK1oye51t3wRdiFsy4z87++OyNss/h6ns=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HpsUulw+lIUnSRyFe4tts5QPz0OkRI8ADu3NPcimEY9jtPltHOaHDYn+8XAzIzEo4vWvQanIkyPY6GpHmeksbrWofcGTzrZ2to15f58JJNUGu63WGzOHpad7cNZ2QOkqa3lzIFnL1bqd4xUw2XYbMfJYStlPAGg+fIiBkz8RCm0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wanadoo.fr; spf=pass smtp.mailfrom=wanadoo.fr; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b=bQGZJQun; arc=none smtp.client-ip=80.12.242.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wanadoo.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wanadoo.fr Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b="bQGZJQun" Received: from localhost.localdomain ([90.11.132.44]) by smtp.orange.fr with ESMTPA id 6uEutykeYoG5N6uEwtJmmW; Fri, 01 Nov 2024 17:11:11 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1730477471; bh=3CFwSVpzoG+hmvmU8SEfKB0VCv9gP01+xTrWzWWleTo=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=bQGZJQunAGFBPQsFk+nbCacJfDfr3s0H52xkLIPhKdGIaU5M3nD7vZ9bUP0ikALw6 TDzunRpL4vjS3rYYS4h+sja48DbR+EeWBEypwQRIt7sQgNDRWPW2hm0mQIGVGOJLCQ XLOewfynDYGi5Yny7ymcc7d6Q4gwEXJe4WJ4BMiJpL78ednE4/+XfGBYrYNOda9iC1 4nBu4JnUksJDdvjDeD156Xe2GAAlP9QNpmW0GyGOCCDoXZoSDziAkFT+QHyiETKH7O RhC7YWGZTOR1O/yUvgbDhr7a3kx4oggoRl5abl8hQAAcvE2Hh644r3NMCpQ9C41nEU /FfsejcR4gUlg== X-ME-Helo: localhost.localdomain X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Fri, 01 Nov 2024 17:11:11 +0100 X-ME-IP: 90.11.132.44 From: Christophe JAILLET To: Selvin Xavier , Jason Gunthorpe , Leon Romanovsky Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-rdma@vger.kernel.org Subject: [PATCH v2 2/2] RDMA/bnxt_re: Remove some dead code Date: Fri, 1 Nov 2024 17:10:57 +0100 Message-ID: X-Mailer: git-send-email 2.47.0 In-Reply-To: <9e48ff955ae55fc39a9eb1eb590d374539eab5ba.1730477345.git.christophe.jaillet@wanadoo.fr> References: <9e48ff955ae55fc39a9eb1eb590d374539eab5ba.1730477345.git.christophe.jaillet@wanadoo.fr> Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 If the probe succeeds, then auxiliary_get_drvdata() can't return a NULL pointer. So several NULL checks can be removed to simplify code. Signed-off-by: Christophe JAILLET --- Compile tested only Changes in v2: - None v1: https://lore.kernel.org/all/bc1135dc297ed2c6f3ca9446a2747b0c89102e61.1729930153.git.christophe.jaillet@wanadoo.fr/ --- drivers/infiniband/hw/bnxt_re/main.c | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/drivers/infiniband/hw/bnxt_re/main.c b/drivers/infiniband/hw/bnxt_re/main.c index 465cec4a1bd4..9eb290ec71a8 100644 --- a/drivers/infiniband/hw/bnxt_re/main.c +++ b/drivers/infiniband/hw/bnxt_re/main.c @@ -300,9 +300,6 @@ static void bnxt_re_shutdown(struct auxiliary_device *adev) struct bnxt_re_en_dev_info *en_info = auxiliary_get_drvdata(adev); struct bnxt_re_dev *rdev; - if (!en_info) - return; - rdev = en_info->rdev; ib_unregister_device(&rdev->ibdev); bnxt_re_dev_uninit(rdev, BNXT_RE_COMPLETE_REMOVE); @@ -316,9 +313,6 @@ static void bnxt_re_stop_irq(void *handle) struct bnxt_qplib_nq *nq; int indx; - if (!en_info) - return; - rdev = en_info->rdev; rcfw = &rdev->rcfw; @@ -339,9 +333,6 @@ static void bnxt_re_start_irq(void *handle, struct bnxt_msix_entry *ent) struct bnxt_qplib_nq *nq; int indx, rc; - if (!en_info) - return; - rdev = en_info->rdev; msix_ent = rdev->en_dev->msix_entries; rcfw = &rdev->rcfw; @@ -1991,10 +1982,6 @@ static void bnxt_re_remove(struct auxiliary_device *adev) struct bnxt_re_dev *rdev; mutex_lock(&bnxt_re_mutex); - if (!en_info) { - mutex_unlock(&bnxt_re_mutex); - return; - } rdev = en_info->rdev; if (rdev) @@ -2043,9 +2030,6 @@ static int bnxt_re_suspend(struct auxiliary_device *adev, pm_message_t state) struct bnxt_en_dev *en_dev; struct bnxt_re_dev *rdev; - if (!en_info) - return 0; - rdev = en_info->rdev; en_dev = en_info->en_dev; mutex_lock(&bnxt_re_mutex); @@ -2090,9 +2074,6 @@ static int bnxt_re_resume(struct auxiliary_device *adev) struct bnxt_re_en_dev_info *en_info = auxiliary_get_drvdata(adev); struct bnxt_re_dev *rdev; - if (!en_info) - return 0; - mutex_lock(&bnxt_re_mutex); /* L2 driver may invoke this callback during device recovery, resume. * reset. Current RoCE driver doesn't recover the device in case of