[PATCH] qed_main: Remove unnecessary cast in kfree

Subsystems: networking drivers, qlogic ql4xxx ethernet driver, the rest

STALE2213d

3 messages, 3 authors, 2020-08-18 · open the first message on its own page

[PATCH] qed_main: Remove unnecessary cast in kfree

From: Xu Wang <hidden>
Date: 2020-08-18 09:11:12

Remove unnecassary casts in the argument to kfree.

Signed-off-by: Xu Wang <redacted>
---
 drivers/net/ethernet/qlogic/qed/qed_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/qlogic/qed/qed_main.c b/drivers/net/ethernet/qlogic/qed/qed_main.c
index 2558cb680db3..44fff7479e46 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_main.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_main.c
@@ -484,7 +484,7 @@ int qed_fill_dev_info(struct qed_dev *cdev,
 
 static void qed_free_cdev(struct qed_dev *cdev)
 {
-	kfree((void *)cdev);
+	kfree(cdev);
 }
 
 static struct qed_dev *qed_alloc_cdev(struct pci_dev *pdev)
-- 
2.17.1

Re: [PATCH] qed_main: Remove unnecessary cast in kfree

From: Jesse Brandeburg <hidden>
Date: 2020-08-18 18:44:08

On Tue, 18 Aug 2020 09:10:56 +0000
Xu Wang [off-list ref] wrote:
Remove unnecassary casts in the argument to kfree.

Signed-off-by: Xu Wang <redacted>
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.

Jesse

Re: [PATCH] qed_main: Remove unnecessary cast in kfree

From: Joe Perches <joe@perches.com>
Date: 2020-08-18 19:03:11

On Tue, 2020-08-18 at 11:44 -0700, Jesse Brandeburg wrote:
On Tue, 18 Aug 2020 09:10:56 +0000
Xu Wang [off-list ref] wrote:
quoted
Remove unnecassary casts in the argument to kfree.

Signed-off-by: Xu Wang <redacted>
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)

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help