GEOM: Remove redundant NULL pointer check before g_free()
Reviewed by: melifaro, pjd, imp Approved by: kp (mentor) Differential Revision: https://reviews.freebsd.org/D37779
This commit is contained in:
parent
f948cb717f
commit
bd5d9037c5
|
@ -208,8 +208,7 @@ g_bde_create_geom(struct gctl_req *req, struct g_class *mp, struct g_provider *p
|
|||
g_access(cp, -1, -1, -1);
|
||||
g_detach(cp);
|
||||
g_destroy_consumer(cp);
|
||||
if (gp->softc != NULL)
|
||||
g_free(gp->softc);
|
||||
g_free(gp->softc);
|
||||
g_destroy_geom(gp);
|
||||
switch (error) {
|
||||
case ENOENT:
|
||||
|
|
|
@ -798,8 +798,7 @@ g_eli_read_metadata_offset(struct g_class *mp, struct g_provider *pp,
|
|||
goto end;
|
||||
/* Metadata was read and decoded successfully. */
|
||||
end:
|
||||
if (buf != NULL)
|
||||
g_free(buf);
|
||||
g_free(buf);
|
||||
if (cp->provider != NULL) {
|
||||
if (cp->acr == 1)
|
||||
g_access(cp, -1, 0, 0);
|
||||
|
|
|
@ -226,8 +226,7 @@ g_ccd_freesc(struct ccd_s *sc)
|
|||
g_free(sc->sc_cinfo);
|
||||
if (sc->sc_itable != NULL) {
|
||||
for (ii = sc->sc_itable; ii->ii_ndisk > 0; ii++)
|
||||
if (ii->ii_index != NULL)
|
||||
g_free(ii->ii_index);
|
||||
g_free(ii->ii_index);
|
||||
g_free(sc->sc_itable);
|
||||
}
|
||||
g_free(sc);
|
||||
|
|
|
@ -701,8 +701,7 @@ g_dev_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag, struct thread
|
|||
error = copyout(new_entries, old_entries, alloc_size);
|
||||
if (old_entries != NULL && rep != NULL)
|
||||
rep->entries = old_entries;
|
||||
if (new_entries != NULL)
|
||||
g_free(new_entries);
|
||||
g_free(new_entries);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -298,15 +298,13 @@ again:
|
|||
if (buf != NULL)
|
||||
head = parse_fis_directory(buf, blksize, offset, offmask);
|
||||
if (head == NULL && offset != 0) {
|
||||
if (buf != NULL)
|
||||
g_free(buf);
|
||||
g_free(buf);
|
||||
offset = 0; /* check the front */
|
||||
goto again;
|
||||
}
|
||||
g_topology_lock();
|
||||
if (head == NULL) {
|
||||
if (buf != NULL)
|
||||
g_free(buf);
|
||||
g_free(buf);
|
||||
return NULL;
|
||||
}
|
||||
/*
|
||||
|
|
|
@ -88,10 +88,8 @@ g_slice_free(struct g_geom *gp)
|
|||
if (gsp == NULL)
|
||||
return;
|
||||
g_free(gsp->slices);
|
||||
if (gsp->hotspot != NULL)
|
||||
g_free(gsp->hotspot);
|
||||
if (gsp->softc != NULL)
|
||||
g_free(gsp->softc);
|
||||
g_free(gsp->hotspot);
|
||||
g_free(gsp->softc);
|
||||
g_free(gsp);
|
||||
}
|
||||
|
||||
|
|
|
@ -215,10 +215,8 @@ endofchecks:
|
|||
g_label_rtrim(label, size);
|
||||
|
||||
error:
|
||||
if (sector0 != NULL)
|
||||
g_free(sector0);
|
||||
if (sector != NULL)
|
||||
g_free(sector);
|
||||
g_free(sector0);
|
||||
g_free(sector);
|
||||
}
|
||||
|
||||
struct g_label_desc g_label_msdosfs = {
|
||||
|
|
|
@ -175,10 +175,8 @@ g_label_ntfs_taste(struct g_consumer *cp, char *label, size_t size)
|
|||
}
|
||||
}
|
||||
done:
|
||||
if (bf != NULL)
|
||||
g_free(bf);
|
||||
if (filerecp != NULL)
|
||||
g_free(filerecp);
|
||||
g_free(bf);
|
||||
g_free(filerecp);
|
||||
}
|
||||
|
||||
struct g_label_desc g_label_ntfs = {
|
||||
|
|
|
@ -249,8 +249,7 @@ g_part_bsd_destroy(struct g_part_table *basetable, struct g_part_parms *gpp)
|
|||
struct g_part_bsd_table *table;
|
||||
|
||||
table = (struct g_part_bsd_table *)basetable;
|
||||
if (table->bbarea != NULL)
|
||||
g_free(table->bbarea);
|
||||
g_free(table->bbarea);
|
||||
table->bbarea = NULL;
|
||||
|
||||
/* Wipe the second sector to clear the partitioning. */
|
||||
|
|
|
@ -534,8 +534,7 @@ gpt_read_hdr(struct g_part_gpt_table *table, struct g_consumer *cp,
|
|||
return (hdr);
|
||||
|
||||
fail:
|
||||
if (hdr != NULL)
|
||||
g_free(hdr);
|
||||
g_free(hdr);
|
||||
g_free(buf);
|
||||
return (NULL);
|
||||
}
|
||||
|
@ -989,14 +988,10 @@ g_part_gpt_read(struct g_part_table *basetable, struct g_consumer *cp)
|
|||
"GEOM: %s: GPT rejected -- may not be recoverable.\n",
|
||||
pp->name);
|
||||
}
|
||||
if (prihdr != NULL)
|
||||
g_free(prihdr);
|
||||
if (pritbl != NULL)
|
||||
g_free(pritbl);
|
||||
if (sechdr != NULL)
|
||||
g_free(sechdr);
|
||||
if (sectbl != NULL)
|
||||
g_free(sectbl);
|
||||
g_free(prihdr);
|
||||
g_free(pritbl);
|
||||
g_free(sechdr);
|
||||
g_free(sectbl);
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
|
@ -1028,11 +1023,9 @@ g_part_gpt_read(struct g_part_table *basetable, struct g_consumer *cp)
|
|||
"strongly advised.\n", pp->name);
|
||||
table->hdr = sechdr;
|
||||
basetable->gpt_corrupt = 1;
|
||||
if (prihdr != NULL)
|
||||
g_free(prihdr);
|
||||
g_free(prihdr);
|
||||
tbl = sectbl;
|
||||
if (pritbl != NULL)
|
||||
g_free(pritbl);
|
||||
g_free(pritbl);
|
||||
} else {
|
||||
if (table->state[GPT_ELT_SECTBL] != GPT_STATE_OK) {
|
||||
printf("GEOM: %s: the secondary GPT table is corrupt "
|
||||
|
@ -1046,11 +1039,9 @@ g_part_gpt_read(struct g_part_table *basetable, struct g_consumer *cp)
|
|||
basetable->gpt_corrupt = 1;
|
||||
}
|
||||
table->hdr = prihdr;
|
||||
if (sechdr != NULL)
|
||||
g_free(sechdr);
|
||||
g_free(sechdr);
|
||||
tbl = pritbl;
|
||||
if (sectbl != NULL)
|
||||
g_free(sectbl);
|
||||
g_free(sectbl);
|
||||
}
|
||||
|
||||
basetable->gpt_first = table->hdr->hdr_lba_start;
|
||||
|
|
|
@ -140,8 +140,7 @@ gv_create_drive(struct gv_softc *sc, struct gv_drive *d)
|
|||
g_topology_unlock();
|
||||
G_VINUM_DEBUG(0, "create drive '%s': unable to update "
|
||||
"access counts", d->name);
|
||||
if (d->hdr != NULL)
|
||||
g_free(d->hdr);
|
||||
g_free(d->hdr);
|
||||
g_free(d);
|
||||
return (GV_ERR_CREATE);
|
||||
}
|
||||
|
|
|
@ -185,8 +185,7 @@ gv_drive_tasted(struct gv_softc *sc, struct g_provider *pp)
|
|||
return;
|
||||
|
||||
failed:
|
||||
if (hdr != NULL)
|
||||
g_free(hdr);
|
||||
g_free(hdr);
|
||||
g_topology_lock();
|
||||
g_access(cp, -1, 0, 0);
|
||||
g_detach(cp);
|
||||
|
|
|
@ -858,8 +858,7 @@ gv_init_complete(struct gv_plex *p, struct bio *bp)
|
|||
*/
|
||||
if (start >= s->drive_offset + s->size) {
|
||||
/* Free the data we initialized. */
|
||||
if (data != NULL)
|
||||
g_free(data);
|
||||
g_free(data);
|
||||
g_topology_assert_not();
|
||||
g_topology_lock();
|
||||
g_access(cp, 0, -1, 0);
|
||||
|
|
Loading…
Reference in New Issue