From patchwork Wed Nov 1 10:49:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 13442754 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0BF9A79E6 for ; Wed, 1 Nov 2023 10:49:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b="T9ffKPOE" Received: from smtp.smtpout.orange.fr (smtp-25.smtpout.orange.fr [80.12.242.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D42E7F3 for ; Wed, 1 Nov 2023 03:49:53 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id y8nGq7z314QsMy8nHquUN7; Wed, 01 Nov 2023 11:49:51 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1698835791; bh=2aMI4kaZmSRgyVFOxUmjlKR0UB3Yi5s4GgkvE78ZjEk=; h=From:To:Cc:Subject:Date; b=T9ffKPOEJxbuViGzfFTHIVaSl3YNHy06fGUxFiCi7i5faO8Gl0+r1nO7E87oWuFhe qM9j9M0OYXNJH6UYiqYK59ZHAxvSX1Ml4JdkAdSZk+SEACj/uRcx626tABaKIioR9s NwOrUp+mXZ3zDlkoQgCkFMGtCoeZt4hz76EcUoS6Nh88geZ1R9CQ4MVnAGnWOlmY9L QSZQ3XO0VCGyF76JzVw4Utsj/FazyT37KvHr1Ic0CzSXC6c3ZjeyOOikUkEl8rNxUA oH75VEzI9pzpR8bH22PFnV6rp/W4feAYqkRH3dvTDmkR4nc5XI899dGkd5vvciOncA l/IMGuRwV/7ow== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Wed, 01 Nov 2023 11:49:51 +0100 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Hans de Goede , Christoph Hellwig , Al Viro Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-fsdevel@vger.kernel.org Subject: [PATCH 1/2] vboxsf: Avoid an spurious warning if load_nls_xxx() fails Date: Wed, 1 Nov 2023 11:49:48 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 If an load_nls_xxx() function fails a few lines above, the 'sbi->bdi_id' is still 0. So, in the error handling path, we will call ida_simple_remove(..., 0) which is not allocated yet. In order to prevent a spurious "ida_free called for id=0 which is not allocated." message, tweak the error handling path and add a new label. Fixes: 0fd169576648 ("fs: Add VirtualBox guest shared folder (vboxsf) support") Signed-off-by: Christophe JAILLET Reviewed-by: Hans de Goede Reviewed-by: Hans de Goede --- fs/vboxsf/super.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/vboxsf/super.c b/fs/vboxsf/super.c index 1fb8f4df60cb..9848af78215b 100644 --- a/fs/vboxsf/super.c +++ b/fs/vboxsf/super.c @@ -151,7 +151,7 @@ static int vboxsf_fill_super(struct super_block *sb, struct fs_context *fc) if (!sbi->nls) { vbg_err("vboxsf: Count not load '%s' nls\n", nls_name); err = -EINVAL; - goto fail_free; + goto fail_destroy_idr; } } @@ -224,6 +224,7 @@ static int vboxsf_fill_super(struct super_block *sb, struct fs_context *fc) ida_simple_remove(&vboxsf_bdi_ida, sbi->bdi_id); if (sbi->nls) unload_nls(sbi->nls); +fail_destroy_idr: idr_destroy(&sbi->ino_idr); kfree(sbi); return err; From patchwork Wed Nov 1 10:49:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 13442755 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 21902107BC for ; Wed, 1 Nov 2023 10:50:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b="E8ypWe7Q" Received: from smtp.smtpout.orange.fr (smtp-26.smtpout.orange.fr [80.12.242.26]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27B6611A for ; Wed, 1 Nov 2023 03:50:00 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id y8nGq7z314QsMy8nNquUNu; Wed, 01 Nov 2023 11:49:58 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1698835798; bh=ZFoT46jhWC+OotEkeda4BBrZIJT+3NpRAKetJm3pBjI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=E8ypWe7QgSH/1hVNdu7NjKwR6dgkPxmlT6wOrOuy+qIK8qWSkzW/in+i1zDWc9/eu sdH7yEEQTPrkmlVN7ZjOA4DONg64WFIS8EFuXXmM732OOb6S3MHo9fxxmQVnca+eR9 aX/AIA9S2BaUtXguHsf4hqAn9ArijpRLukoYpS0OnvyAsBQYAY5O32aU/nGU6DOQWD N/5B1xKkyjd/ToWslTf2CcI+xF9JiwgGjz5mIMYBzAa5Ux18Tg6J9O70Z3aZCfKWci IqtBFU07TJKh4AZ9mmpruRlQFtzx+TLpIEw8fbIe1g+XHoT07GN88kC+36ocS9iRBz VHbrGWbtQfNIQ== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Wed, 01 Nov 2023 11:49:58 +0100 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Hans de Goede Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-fsdevel@vger.kernel.org Subject: [PATCH 2/2] vboxsf: Remove usage of the deprecated ida_simple_xx() API Date: Wed, 1 Nov 2023 11:49:49 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 ida_alloc() and ida_free() should be preferred to the deprecated ida_simple_get() and ida_simple_remove(). This is less verbose. Signed-off-by: Christophe JAILLET --- fs/vboxsf/super.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/vboxsf/super.c b/fs/vboxsf/super.c index 9848af78215b..0f67f2d8b651 100644 --- a/fs/vboxsf/super.c +++ b/fs/vboxsf/super.c @@ -155,7 +155,7 @@ static int vboxsf_fill_super(struct super_block *sb, struct fs_context *fc) } } - sbi->bdi_id = ida_simple_get(&vboxsf_bdi_ida, 0, 0, GFP_KERNEL); + sbi->bdi_id = ida_alloc(&vboxsf_bdi_ida, GFP_KERNEL); if (sbi->bdi_id < 0) { err = sbi->bdi_id; goto fail_free; @@ -221,7 +221,7 @@ static int vboxsf_fill_super(struct super_block *sb, struct fs_context *fc) vboxsf_unmap_folder(sbi->root); fail_free: if (sbi->bdi_id >= 0) - ida_simple_remove(&vboxsf_bdi_ida, sbi->bdi_id); + ida_free(&vboxsf_bdi_ida, sbi->bdi_id); if (sbi->nls) unload_nls(sbi->nls); fail_destroy_idr: @@ -269,7 +269,7 @@ static void vboxsf_put_super(struct super_block *sb) vboxsf_unmap_folder(sbi->root); if (sbi->bdi_id >= 0) - ida_simple_remove(&vboxsf_bdi_ida, sbi->bdi_id); + ida_free(&vboxsf_bdi_ida, sbi->bdi_id); if (sbi->nls) unload_nls(sbi->nls);