Skip to contentSkip to conversation

xfs_spaceman: fix potential memory leak by malloc in scan_ag

PATCH In review Bill O'Donnell 3 participants 3 messages Jun 29, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs_spaceman: fix potential memory leak by malloc in scan_ag

scan_ag mallocs memory that is potentially leaked. Add a free to alleviate the potential leak.

Fixes CoverityScan CID#1413772 (RESOURCE_LEAK)

---
 spaceman/freesp.c | 2 ++
 1 file changed, 2 insertions(+)
spaceman/freesp.c +2 -0
index 22aec821..367c95d1 100644
@@ -239,7 +239,9 @@ scan_ag(
 			printf(_("%10u %10llu %10llu\n"), agno, freeexts,
 					freeblks);
 	}
+	free(fsmap);
 }
+
 static void
 aglistadd(
 	char		*a)
Signature · 1 line
2.13.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Bill O'Donnell

scan_ag mallocs memory that is potentially leaked. Add a free to alleviate the potential leak.

Fixes CoverityScan CID#1413772 (RESOURCE_LEAK)

/me feels like the coverity tags he's seen tend to take the format of:

    Addresses-Coverity-ID: 1091173

or
Detected by CoverityScan, CID#1419681 ("Explicit null dereferenced")

though to be honest I don't know that there's really a standard.

<shrug> It probably ought to use one of the two more common formats, but maybe I can just ask Eric to prettyplease fix it on the way in. :)

Quoted 1 line

Looks ok,

--D

Quoted 25 lines
---
 spaceman/freesp.c | 2 ++
 1 file changed, 2 insertions(+)
spaceman/freesp.c +2 -0
index 22aec821..367c95d1 100644
@@ -239,7 +239,9 @@ scan_ag(
 			printf(_("%10u %10llu %10llu\n"), agno, freeexts,
 					freeblks);
 	}
+	free(fsmap);
 }
+
 static void
 aglistadd(
 	char		*a)
Signature · 6 lines
2.13.0

--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw
Quoted 8 lines · Darrick J. Wong
Quoted 4 lines · Bill O'Donnell

scan_ag mallocs memory that is potentially leaked. Add a free to alleviate the potential leak.

Fixes CoverityScan CID#1413772 (RESOURCE_LEAK)

/me feels like the coverity tags he's seen tend to take the format of:

Quoted 8 lines
    Addresses-Coverity-ID: 1091173

or
Detected by CoverityScan, CID#1419681 ("Explicit null dereferenced")

though to be honest I don't know that there's really a standard.

<shrug> It probably ought to use one of the two more common formats, but maybe I can just ask Eric to prettyplease fix it on the way in. :)

Agreed, will do.

(there are a couple different formats already in the history, but best not to invent more as we go) :)

-Eric

Quoted 38 lines
Quoted 2 lines

Looks ok,

--D

Quoted 25 lines
---
 spaceman/freesp.c | 2 ++
 1 file changed, 2 insertions(+)
spaceman/freesp.c +2 -0
index 22aec821..367c95d1 100644
@@ -239,7 +239,9 @@ scan_ag(
 			printf(_("%10u %10llu %10llu\n"), agno, freeexts,
 					freeblks);
 	}
+	free(fsmap);
 }
+
 static void
 aglistadd(
 	char		*a)
Signature · 6 lines
2.13.0

--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html