From patchwork Thu Dec 17 05:44:12 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 68619 Received: from hormel.redhat.com (hormel1.redhat.com [209.132.177.33]) by demeter.kernel.org (8.14.3/8.14.2) with ESMTP id nBI7TxZS028469 for ; Fri, 18 Dec 2009 07:29:59 GMT Received: from listman.util.phx.redhat.com (listman.util.phx.redhat.com [10.8.4.110]) by hormel.redhat.com (Postfix) with ESMTP id 6AF3E8E0855; Thu, 17 Dec 2009 00:45:43 -0500 (EST) Received: from int-mx05.intmail.prod.int.phx2.redhat.com (nat-pool.util.phx.redhat.com [10.8.5.200]) by listman.util.phx.redhat.com (8.13.1/8.13.1) with ESMTP id nBH5jgfG001569 for ; Thu, 17 Dec 2009 00:45:42 -0500 Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.5]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nBH5jgms027209 for ; Thu, 17 Dec 2009 00:45:42 -0500 Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nBH5jQes013169 for ; Thu, 17 Dec 2009 00:45:26 -0500 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.221.2]) by mx2.suse.de (Postfix) with ESMTP id F40A08891E for ; Thu, 17 Dec 2009 06:45:25 +0100 (CET) From: neilb@suse.de To: dm-devel@redhat.com Date: Thu, 17 Dec 2009 16:44:12 +1100 Message-Id: <20091217054520.996066834@suse.de> User-Agent: quilt/0.48-1 References: <20091217054410.410634166@suse.de> Content-Disposition: inline; filename=dmraid-fdleak.patch X-RedHat-Spam-Score: -3.534 (AWL,RCVD_IN_DNSWL_MED,SUBJECT_FUZZY_TION) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 X-Scanned-By: MIMEDefang 2.67 on 10.5.110.5 X-loop: dm-devel@redhat.com Subject: [dm-devel] [dmraid 2/4] Avoid fd leak in remove_device_partitions. X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.5 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com --- dmraid-16.orig/lib/device/partition.c +++ dmraid-16/lib/device/partition.c @@ -30,12 +30,15 @@ _remove_subset_partitions(struct lib_con /* There is no way to enumerate partitions */ for (part.pno = 1; part.pno <= 256; part.pno++) { if (ioctl(fd, BLKPG, &io) < 0 && errno != ENXIO && - (part.pno < 16 || errno != EINVAL)) + (part.pno < 16 || errno != EINVAL)) { + close(fd); LOG_ERR(lc, 0, "removing part %d from %s: %s\n", part.pno, rd->di->path, strerror(errno)); + } } + close(fd); } return 1; }