From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sven Schnelle Subject: [AFS] prevent double cell registration Date: Fri, 21 Mar 2008 23:39:30 +0100 Message-ID: <868x0bog65.fsf@deprecated.bitebene.org> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" Cc: linux-fsdevel@vger.kernel.org To: dhowells@redhat.com Return-path: Received: from smtp.duncanthrax.net ([89.31.1.170]:47495 "EHLO smtp.duncanthrax.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1763756AbYCUXBm (ORCPT ); Fri, 21 Mar 2008 19:01:42 -0400 Sender: linux-fsdevel-owner@vger.kernel.org List-ID: --=-=-= Content-Transfer-Encoding: quoted-printable kafs doesn't check if the cell already exists - so if you do an echo "add newcell.org 1.2.3.4" >/proc/fs/afs/cells it will try to create this cell again. kobject will also complain about a double registration. To prevent such problems, return -EEXIST in that case. =2D-- fs/afs/cell.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/fs/afs/cell.c b/fs/afs/cell.c index 970d38f..87934b3 100644 =2D-- a/fs/afs/cell.c +++ b/fs/afs/cell.c @@ -127,6 +127,15 @@ struct afs_cell *afs_cell_create(const char *name, cha= r *vllist) =20 _enter("%s,%s", name, vllist); =20 + read_lock(&afs_cells_lock); + list_for_each_entry(cell, &afs_cells, link) { + if(!strcasecmp(cell->name, name)) { + read_unlock(&afs_cells_lock); + return ERR_PTR(-EEXIST); + } + } + read_unlock(&afs_cells_lock); + cell =3D afs_cell_alloc(name, vllist); if (IS_ERR(cell)) { _leave(" =3D %ld", PTR_ERR(cell)); =2D-=20 1.5.4.3 --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFH5DkkIp3lOhiYlUoRAgd1AJ0d2CHt2via3gJEzsxLO0aDQB93WQCfTW2/ LVuvfeXfq4jjS3jS2dl6ROQ= =mi6x -----END PGP SIGNATURE----- --=-=-=--