Page MenuHomeFreeBSD

Don't leak rsector/sector in mp_label(..); use calloc instead of malloc + memset
ClosedPublic

Authored by ngie on Dec 9 2015, 2:15 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Nov 16, 11:29 AM
Unknown Object (File)
Mon, Nov 4, 6:17 AM
Unknown Object (File)
Mon, Nov 4, 6:17 AM
Unknown Object (File)
Mon, Nov 4, 5:57 AM
Unknown Object (File)
Sep 18 2024, 3:16 PM
Unknown Object (File)
Sep 18 2024, 3:16 PM
Unknown Object (File)
Sep 18 2024, 3:13 PM
Unknown Object (File)
Sep 15 2024, 5:49 AM
Subscribers

Details

Reviewers
mav
Summary

Plug memory leaks in mp_label(..)

Don't leak rsector/sector in mp_label(..); use calloc instead of malloc + memset

MFC after: 1 week
Reported by: cppcheck
Sponsored by: EMC / Isilon Storage Division

Test Plan

% mdconfig -a -t malloc -s 25m
md0
% gmultipath label mpath md0
% gmultipath list
Geom name: mpath
Type: AUTOMATIC
Mode: Active/Passive
UUID: 21142ac6-9e1a-11e5-951e-000c29d8596e
State: DEGRADED
Providers:

  1. Name: multipath/mpath Mediasize: 26213888 (25M) Sectorsize: 512 Mode: r0w0e0 State: DEGRADED

Consumers:

  1. Name: md0 Mediasize: 26214400 (25M) Sectorsize: 512 Mode: r1w1e1 State: ACTIVE

% gmultipath add mpath md1
% gmultipath list
Geom name: mpath
Type: AUTOMATIC
Mode: Active/Passive
UUID: 21142ac6-9e1a-11e5-951e-000c29d8596e
State: OPTIMAL
Providers:

  1. Name: multipath/mpath Mediasize: 26213888 (25M) Sectorsize: 512 Mode: r0w0e0 State: OPTIMAL

Consumers:

  1. Name: md0 Mediasize: 26214400 (25M) Sectorsize: 512 Mode: r1w1e1 State: ACTIVE
  2. Name: md1 Mediasize: 26214400 (25M) Sectorsize: 512 Mode: r1w1e1 State: PASSIVE

%

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 1497
Build 1503: arc lint + arc unit

Event Timeline

ngie retitled this revision from to Don't leak rsector/sector in mp_label(..); use calloc instead of malloc + memset.
ngie updated this object.
ngie edited the test plan for this revision. (Show Details)
ngie added a reviewer: mav.
ngie added subscribers: benno, emaste.
mav edited edge metadata.

I see no point in original NULL assignment. Other then that I have no objections.

This revision is now accepted and ready to land.Dec 9 2015, 7:06 PM
In D4450#94151, @mav wrote:

I see no point in original NULL assignment. Other then that I have no objections.

Yeah, you're right. I'll remove them from the final diff.

Thanks!