From patchwork Fri Aug 10 19:16:31 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 1306471 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 47F06DF266 for ; Fri, 10 Aug 2012 19:17:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751254Ab2HJTRw (ORCPT ); Fri, 10 Aug 2012 15:17:52 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:51781 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750932Ab2HJTRv (ORCPT ); Fri, 10 Aug 2012 15:17:51 -0400 Received: by pbbrr13 with SMTP id rr13so3159448pbb.19 for ; Fri, 10 Aug 2012 12:17:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding:x-gm-message-state; bh=hRWzi4mDKT0RGGp4j8M5uhP6yZQU2Tj7trQmB2L4zE4=; b=hF0LXWgJMIHPGAS0rmKjg+5GhPRJDRtch4P8zw2WyMUX9gbj474K0OeJEcmgr8XA88 pDDhbAkOiE/mk1W1XO0whCrUPF7YhlxCVFyVg8DEB8CszIirKkqynNZFyw/heOBYeQ8e 3XUfFNrpKJLyieluySDjMCp+IYNJquhHCiHzdxKXdpIL6o3IHbKouVsPj7UCqvt8NmXW l4qPlUT0pXIW/5RuvQk9YNTaXv/YmPhMZ+cWb1Po4XWeUtvzrGYEblPlOgMGciemlRCi PzRjV6hYT4rzH0kULIBcsE8OTX4DbmWRLZPbGHeljHgHIVj38pTFGhsJ9jAdpWcYGpIx gt2A== Received: by 10.68.191.4 with SMTP id gu4mr1216591pbc.50.1344626271587; Fri, 10 Aug 2012 12:17:51 -0700 (PDT) Received: from [192.168.107.150] ([38.122.20.226]) by mx.google.com with ESMTPS id rm9sm3861769pbc.72.2012.08.10.12.17.35 (version=SSLv3 cipher=OTHER); Fri, 10 Aug 2012 12:17:51 -0700 (PDT) Message-ID: <50255E0F.4070406@inktank.com> Date: Fri, 10 Aug 2012 12:16:31 -0700 From: Alex Elder User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 MIME-Version: 1.0 To: ceph-devel@vger.kernel.org Subject: [PATCH] rbd: drop dev reference on error in rbd_open() X-Gm-Message-State: ALoCoQkViMyPUXS0DcL0fLj6X+LQ2bV4pWXOmPt75gxXgP0YzHutWQVCymMNYrjGhtTyg7Kxh9ga Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org If a read-only rbd device is opened for writing in rbd_open(), it returns without dropping the just-acquired device reference. Fix this by moving the read-only check before getting the reference. Signed-off-by: Alex Elder Reviewed-by: Yehuda Sadeh Reviewed-by: Josh Durgin --- drivers/block/rbd.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: b/drivers/block/rbd.c =================================================================== --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -246,13 +246,12 @@ static int rbd_open(struct block_device { struct rbd_device *rbd_dev = bdev->bd_disk->private_data; - rbd_get_dev(rbd_dev); - - set_device_ro(bdev, rbd_dev->read_only); - if ((mode & FMODE_WRITE) && rbd_dev->read_only) return -EROFS; + rbd_get_dev(rbd_dev); + set_device_ro(bdev, rbd_dev->read_only); + return 0; }