From: NeilBrown Date: Thu, 13 Aug 2009 05:02:39 +0000 (+1000) Subject: super1: remove fd leak when opening /dev/urandom X-Git-Tag: mdadm-3.0.1~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7cbeb80e900d2cbb47c6de75826769b5addb4867;p=thirdparty%2Fmdadm.git super1: remove fd leak when opening /dev/urandom As reported in https://bugzilla.novell.com/show_bug.cgi?id=527722 I forgot to close the fd after reading the random number. Signed-off-by: NeilBrown --- diff --git a/super1.c b/super1.c index 056b93bb..fee22a97 100644 --- a/super1.c +++ b/super1.c @@ -685,6 +685,8 @@ static int update_super1(struct supertype *st, struct mdinfo *info, __u32 r[4] = {random(), random(), random(), random()}; memcpy(sb->device_uuid, r, 16); } + if (rfd >= 0) + close(rfd); sb->dev_roles[i] = __cpu_to_le16(info->disk.raid_disk);