From patchwork Tue Jul 12 13:01:09 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masatake YAMATO X-Patchwork-Id: 968332 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p6CD1II7013731 for ; Tue, 12 Jul 2011 13:01:19 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753394Ab1GLNBR (ORCPT ); Tue, 12 Jul 2011 09:01:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49607 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753143Ab1GLNBR (ORCPT ); Tue, 12 Jul 2011 09:01:17 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p6CD1BH9021264 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 12 Jul 2011 09:01:11 -0400 Received: from localhost (beach.nrt.redhat.com [10.64.200.71]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p6CD19r6006308; Tue, 12 Jul 2011 09:01:10 -0400 Date: Tue, 12 Jul 2011 22:01:09 +0900 (JST) Message-Id: <20110712.220109.419121694701200961.yamato@redhat.com> To: bfields@fieldses.org Cc: linux-nfs@vger.kernel.org, steved@redhat.com Subject: [PATCH v3] closing fd associated with /proc/fs/nfsd/export_features From: Masatake YAMATO In-Reply-To: <20110712.213817.1045173784079879730.yamato@redhat.com> References: <20110712.114700.814616059257545652.yamato@redhat.com> <20110712104652.GA2162@fieldses.org> <20110712.213817.1045173784079879730.yamato@redhat.com> Organization: Red Hat Japan, Inc. Mime-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 12 Jul 2011 13:01:38 +0000 (UTC) Very sorry for posting again and again. fd shuold be closed even if read is failed. Signed-off-by: Masatake YAMATO > Sorry, my patch has a serious bug. > The value returned from read() is stored to fd. > So fd should not be passed to close(). > > I rearranged the code as below. > > Signed-off-by: Masatake YAMATO > > diff --git a/support/nfs/exports.c b/support/nfs/exports.c > index c250383..744c01b 100644 > --- a/support/nfs/exports.c > +++ b/support/nfs/exports.c > @@ -784,9 +784,10 @@ struct export_features *get_export_features(void) > fd = open(path, O_RDONLY); > if (fd == -1) > goto good; > - fd = read(fd, buf, 50); > - if (fd == -1) > + c = read(fd, buf, 50); > + if (c == -1) > goto err; > + close(fd); > c = sscanf(buf, "%x %x", &ef.flags, &ef.secinfo_flags); > if (c != 2) > goto err; > > >> On Tue, Jul 12, 2011 at 11:47:00AM +0900, Masatake YAMATO wrote: >>> A fd associated with /proc/fs/nfsd/export_features opened in get_export_features is >>> not closed. >>> >>> >>> Signed-off-by: Masatake YAMATO >> Acked-by: J. Bruce Fields >>> >>> diff --git a/support/nfs/exports.c b/support/nfs/exports.c >>> index c250383..819a18a 100644 >>> --- a/support/nfs/exports.c >>> +++ b/support/nfs/exports.c >>> @@ -787,6 +787,7 @@ struct export_features *get_export_features(void) >>> fd = read(fd, buf, 50); >>> if (fd == -1) >>> goto err; >>> + close(fd); >>> c = sscanf(buf, "%x %x", &ef.flags, &ef.secinfo_flags); >>> if (c != 2) >>> goto err; >>> -- >>> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in >>> the body of a message to majordomo@vger.kernel.org >>> More majordomo info at http://vger.kernel.org/majordomo-info.html >> -- >> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in >> the body of a message to majordomo@vger.kernel.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html > -- > To unsubscribe from this list: send the line "unsubscribe linux-nfs" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html --- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/support/nfs/exports.c b/support/nfs/exports.c index c250383..c96500f 100644 --- a/support/nfs/exports.c +++ b/support/nfs/exports.c @@ -784,8 +784,9 @@ struct export_features *get_export_features(void) fd = open(path, O_RDONLY); if (fd == -1) goto good; - fd = read(fd, buf, 50); - if (fd == -1) + c = read(fd, buf, 50); + close(fd); + if (c == -1) goto err; c = sscanf(buf, "%x %x", &ef.flags, &ef.secinfo_flags); if (c != 2)