Commit d1ec20a5 authored by Alex Dewar's avatar Alex Dewar Committed by Martin K. Petersen

scsi: aic7xxx: Remove unnecessary NULL checks before kfree

There are a number of places in the aic7xxx driver where a NULL check is
performed before a kfree(). However, kfree() already performs NULL checks
so this is unnecessary. Remove the checks.

Issue identified with Coccinelle.

Link: https://lore.kernel.org/r/20200403164712.49579-1-alex.dewar@gmx.co.ukSigned-off-by: default avatarAlex Dewar <alex.dewar@gmx.co.uk>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 9cd7d494
...@@ -3662,8 +3662,7 @@ ahd_free_tstate(struct ahd_softc *ahd, u_int scsi_id, char channel, int force) ...@@ -3662,8 +3662,7 @@ ahd_free_tstate(struct ahd_softc *ahd, u_int scsi_id, char channel, int force)
return; return;
tstate = ahd->enabled_targets[scsi_id]; tstate = ahd->enabled_targets[scsi_id];
if (tstate != NULL) kfree(tstate);
kfree(tstate);
ahd->enabled_targets[scsi_id] = NULL; ahd->enabled_targets[scsi_id] = NULL;
} }
#endif #endif
...@@ -6119,8 +6118,7 @@ ahd_set_unit(struct ahd_softc *ahd, int unit) ...@@ -6119,8 +6118,7 @@ ahd_set_unit(struct ahd_softc *ahd, int unit)
void void
ahd_set_name(struct ahd_softc *ahd, char *name) ahd_set_name(struct ahd_softc *ahd, char *name)
{ {
if (ahd->name != NULL) kfree(ahd->name);
kfree(ahd->name);
ahd->name = name; ahd->name = name;
} }
...@@ -6181,12 +6179,9 @@ ahd_free(struct ahd_softc *ahd) ...@@ -6181,12 +6179,9 @@ ahd_free(struct ahd_softc *ahd)
kfree(ahd->black_hole); kfree(ahd->black_hole);
} }
#endif #endif
if (ahd->name != NULL) kfree(ahd->name);
kfree(ahd->name); kfree(ahd->seep_config);
if (ahd->seep_config != NULL) kfree(ahd->saved_stack);
kfree(ahd->seep_config);
if (ahd->saved_stack != NULL)
kfree(ahd->saved_stack);
kfree(ahd); kfree(ahd);
return; return;
} }
......
...@@ -2178,8 +2178,7 @@ ahc_free_tstate(struct ahc_softc *ahc, u_int scsi_id, char channel, int force) ...@@ -2178,8 +2178,7 @@ ahc_free_tstate(struct ahc_softc *ahc, u_int scsi_id, char channel, int force)
if (channel == 'B') if (channel == 'B')
scsi_id += 8; scsi_id += 8;
tstate = ahc->enabled_targets[scsi_id]; tstate = ahc->enabled_targets[scsi_id];
if (tstate != NULL) kfree(tstate);
kfree(tstate);
ahc->enabled_targets[scsi_id] = NULL; ahc->enabled_targets[scsi_id] = NULL;
} }
#endif #endif
...@@ -4453,8 +4452,7 @@ ahc_set_unit(struct ahc_softc *ahc, int unit) ...@@ -4453,8 +4452,7 @@ ahc_set_unit(struct ahc_softc *ahc, int unit)
void void
ahc_set_name(struct ahc_softc *ahc, char *name) ahc_set_name(struct ahc_softc *ahc, char *name)
{ {
if (ahc->name != NULL) kfree(ahc->name);
kfree(ahc->name);
ahc->name = name; ahc->name = name;
} }
...@@ -4515,10 +4513,8 @@ ahc_free(struct ahc_softc *ahc) ...@@ -4515,10 +4513,8 @@ ahc_free(struct ahc_softc *ahc)
kfree(ahc->black_hole); kfree(ahc->black_hole);
} }
#endif #endif
if (ahc->name != NULL) kfree(ahc->name);
kfree(ahc->name); kfree(ahc->seep_config);
if (ahc->seep_config != NULL)
kfree(ahc->seep_config);
kfree(ahc); kfree(ahc);
return; return;
} }
...@@ -4927,8 +4923,7 @@ ahc_fini_scbdata(struct ahc_softc *ahc) ...@@ -4927,8 +4923,7 @@ ahc_fini_scbdata(struct ahc_softc *ahc)
case 0: case 0:
break; break;
} }
if (scb_data->scbarray != NULL) kfree(scb_data->scbarray);
kfree(scb_data->scbarray);
} }
static void static void
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment