[PATCH] Staging: dgnc: Fix kfree(NULL) is safe check not required in dgnc_driver.c

174 views
Skip to first unread message

Monam Agarwal

unread,
Mar 1, 2014, 5:09:22 PM3/1/14
to opw-k...@googlegroups.com
This patch fixes the following checkpatch.pl issues
WARNING: kfree(NULL) is safe this check is probably not required

Signed-off-by: Monam Agarwal <monamag...@gmail.com>
---
drivers/staging/dgnc/dgnc_driver.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c b/drivers/staging/dgnc/dgnc_driver.c
index c204266..c1d7292 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -451,20 +451,17 @@ static void dgnc_cleanup_board(struct dgnc_board *brd)
/* Free all allocated channels structs */
for (i = 0; i < MAXPORTS ; i++) {
if (brd->channels[i]) {
- if (brd->channels[i]->ch_rqueue)
- kfree(brd->channels[i]->ch_rqueue);
- if (brd->channels[i]->ch_equeue)
- kfree(brd->channels[i]->ch_equeue);
- if (brd->channels[i]->ch_wqueue)
- kfree(brd->channels[i]->ch_wqueue);

+ kfree(brd->channels[i]->ch_rqueue);
+ kfree(brd->channels[i]->ch_equeue);
+ kfree(brd->channels[i]->ch_wqueue);
+
kfree(brd->channels[i]);
brd->channels[i] = NULL;
}
}

- if (brd->flipbuf)
- kfree(brd->flipbuf);
+ kfree(brd->flipbuf);

dgnc_Board[brd->boardnum] = NULL;

--
1.7.9.5

Paul E. McKenney

unread,
Mar 1, 2014, 8:34:45 PM3/1/14
to Monam Agarwal, opw-k...@googlegroups.com
Looks good, but why the extra blank line?

Thanx, Paul

> kfree(brd->channels[i]);
> brd->channels[i] = NULL;
> }
> }
>
> - if (brd->flipbuf)
> - kfree(brd->flipbuf);
> + kfree(brd->flipbuf);
>
> dgnc_Board[brd->boardnum] = NULL;
>
> --
> 1.7.9.5
>
> --
> You received this message because you are subscribed to the Google Groups "opw-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to opw-kernel+...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

Monam Agarwal

unread,
Mar 2, 2014, 5:17:46 AM3/2/14
to pau...@linux.vnet.ibm.com, opw-k...@googlegroups.com
These were kfree operations on two different kinds of variables. So to
increase clarity I introduced this extra line.

Greg KH

unread,
Mar 7, 2014, 4:35:15 PM3/7/14
to Monam Agarwal, opw-k...@googlegroups.com
On Sun, Mar 02, 2014 at 03:39:22AM +0530, Monam Agarwal wrote:
This patch adds unneeded whitespace, always run your patches through
checkpatch before sending them out, you don't want to add problems when
you are trying to clean them up :)

Monam Agarwal

unread,
Mar 9, 2014, 12:58:59 AM3/9/14
to opw-k...@googlegroups.com
This patch fixes the following checkpatch.pl issues
WARNING: kfree(NULL) is safe this check is probably not required

Signed-off-by: Monam Agarwal <monamag...@gmail.com>
---
Changes since version1:
*removal of extra line introduced in patch v1
*removal of checkpatch.pl warnings in previous patch
---
drivers/staging/dgnc/dgnc_driver.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c b/drivers/staging/dgnc/dgnc_driver.c
index c204266..c1d7292 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -451,20 +451,17 @@ static void dgnc_cleanup_board(struct dgnc_board *brd)
/* Free all allocated channels structs */
for (i = 0; i < MAXPORTS ; i++) {
if (brd->channels[i]) {
- if (brd->channels[i]->ch_rqueue)
- kfree(brd->channels[i]->ch_rqueue);
- if (brd->channels[i]->ch_equeue)
- kfree(brd->channels[i]->ch_equeue);
- if (brd->channels[i]->ch_wqueue)
- kfree(brd->channels[i]->ch_wqueue);
+ kfree(brd->channels[i]->ch_rqueue);
+ kfree(brd->channels[i]->ch_equeue);
+ kfree(brd->channels[i]->ch_wqueue);
kfree(brd->channels[i]);
brd->channels[i] = NULL;
}
}

- if (brd->flipbuf)
- kfree(brd->flipbuf);
+ kfree(brd->flipbuf);

dgnc_Board[brd->boardnum] = NULL;

--
1.7.9.5

Paul E. McKenney

unread,
Mar 10, 2014, 11:06:19 AM3/10/14
to Monam Agarwal, opw-k...@googlegroups.com
On Sun, Mar 09, 2014 at 11:28:59AM +0530, Monam Agarwal wrote:
> This patch fixes the following checkpatch.pl issues
> WARNING: kfree(NULL) is safe this check is probably not required
>
> Signed-off-by: Monam Agarwal <monamag...@gmail.com>

Acked-by: Paul E. McKenney <pau...@linux.vnet.ibm.com>
> --
> You received this message because you are subscribed to the Google Groups "opw-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to opw-kernel+...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

Waskiewicz Jr, Peter P

unread,
Mar 10, 2014, 5:51:43 PM3/10/14
to Monam Agarwal, opw-k...@googlegroups.com
Did you hand-edit this patch? This hunk right here is corrupt, there
should be an empty line, and it's not applying (I just went to
hand-apply and noticed what's wrong).

Please respin the patch against the latest tree if you can please.
Outside of hand-editing the patch, I'm not sure what happened here.

> kfree(brd->channels[i]);

-PJ

--
PJ Waskiewicz Open Source Technology Center
peter.p.wa...@intel.com Intel Corp.
Reply all
Reply to author
Forward
0 new messages