lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Tue, 18 Aug 2020 12:03:02 -0700
From:   Joe Perches <joe@...ches.com>
To:     Jesse Brandeburg <jesse.brandeburg@...el.com>,
        Xu Wang <vulab@...as.ac.cn>
Cc:     aelior@...vell.com, GR-everest-linux-l2@...vell.com,
        davem@...emloft.net, kuba@...nel.org, netdev@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] qed_main: Remove unnecessary cast in kfree

On Tue, 2020-08-18 at 11:44 -0700, Jesse Brandeburg wrote:
> On Tue, 18 Aug 2020 09:10:56 +0000
> Xu Wang <vulab@...as.ac.cn> wrote:
> 
> > Remove unnecassary casts in the argument to kfree.
> > 
> > Signed-off-by: Xu Wang <vulab@...as.ac.cn>
> 
> You seem to have several of these patches, they should be sent in a
> series with the series patch subject (for example):
> [PATCH net-next 0/n] fix up casts on kfree
> 
> Did you use a coccinelle script to find these? 
> 
> They could all have Fixes tags. I'd resend the whole bunch as a series.
> 
> Since this has no functional change, you could mention that in the
> series commit message text.

Commits with no functional change generally should
not be marked with Fixes:

And some wrapper functions might as well be removed
and just kfree used in-place instead.

Something like:
---
 drivers/net/ethernet/qlogic/qed/qed_main.c | 29 ++++++-----------------------
 1 file changed, 6 insertions(+), 23 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_main.c b/drivers/net/ethernet/qlogic/qed/qed_main.c
index 2558cb680db3..961adb4d8910 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_main.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_main.c
@@ -482,24 +482,6 @@ int qed_fill_dev_info(struct qed_dev *cdev,
 	return 0;
 }
 
-static void qed_free_cdev(struct qed_dev *cdev)
-{
-	kfree((void *)cdev);
-}
-
-static struct qed_dev *qed_alloc_cdev(struct pci_dev *pdev)
-{
-	struct qed_dev *cdev;
-
-	cdev = kzalloc(sizeof(*cdev), GFP_KERNEL);
-	if (!cdev)
-		return cdev;
-
-	qed_init_struct(cdev);
-
-	return cdev;
-}
-
 /* Sets the requested power state */
 static int qed_set_power_state(struct qed_dev *cdev, pci_power_t state)
 {
@@ -618,9 +600,11 @@ static struct qed_dev *qed_probe(struct pci_dev *pdev,
 	struct qed_dev *cdev;
 	int rc;
 
-	cdev = qed_alloc_cdev(pdev);
+	cdev = kzalloc(sizeof(*cdev), GFP_KERNEL);
 	if (!cdev)
-		goto err0;
+		return NULL;
+
+	qed_init_struct(cdev);
 
 	cdev->drv_type = DRV_ID_DRV_TYPE_LINUX;
 	cdev->protocol = params->protocol;
@@ -658,8 +642,7 @@ static struct qed_dev *qed_probe(struct pci_dev *pdev,
 err2:
 	qed_free_pci(cdev);
 err1:
-	qed_free_cdev(cdev);
-err0:
+	kfree(cdev);
 	return NULL;
 }
 
@@ -676,7 +659,7 @@ static void qed_remove(struct qed_dev *cdev)
 
 	qed_devlink_unregister(cdev);
 
-	qed_free_cdev(cdev);
+	kfree(cdev);
 }
 
 static void qed_disable_msix(struct qed_dev *cdev)


Powered by blists - more mailing lists