From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 500E0C4332F for ; Thu, 2 Nov 2023 12:30:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376313AbjKBMaW (ORCPT ); Thu, 2 Nov 2023 08:30:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347475AbjKBMaS (ORCPT ); Thu, 2 Nov 2023 08:30:18 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B96F4137; Thu, 2 Nov 2023 05:30:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=lLbEJjW9cmFlpV3shV0/lRN5bbIbbVeY+zCDD51WFMw=; b=pTHDt05lcN/Cquxk27BSdyCKgy hzNRR4QinKiGSXAT+IvNDIldJJss87ffYgIHYqGWe7fkQJzfVfWVAmqcKYjo5QW15CWq0u59MUihn h2bKPJMu4MRWcgPl8ZiIlyIEoGDnEougjsws6T/D40F/HB6pPn+HJTg62MGa5fiRnKOvCbXPhzsSh tRaYFDh46FTFcvpSzkTKCviXehU/1CUav+ATjAzMWf5BC/65dJTg5yFLVYZ1U4bHiTU7OoCJBejvv 63covoTNDX8ZnRkSKNGOtl2gkFc4ePV5QLeaNOdmdnfFQK3GRq+bFLrxvs56WghPaAURYyAAsZZ12 7Ch5wJxQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qyWpn-004Qbg-9a; Thu, 02 Nov 2023 12:30:03 +0000 Date: Thu, 2 Nov 2023 12:30:03 +0000 From: Matthew Wilcox To: Christophe JAILLET Cc: Hans de Goede , Christoph Hellwig , Al Viro , linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH 1/2] vboxsf: Avoid an spurious warning if load_nls_xxx() fails Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 01, 2023 at 11:49:48AM +0100, Christophe JAILLET wrote: > 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. That's not spurious! You're freeing something that wasn't allocated. A good quality malloc allocation will warn you if you free() a random pointer. I agree with everything abuot this patch (and the next) except for the changelog. > Fixes: 0fd169576648 ("fs: Add VirtualBox guest shared folder (vboxsf) support") > Signed-off-by: Christophe JAILLET > --- > 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; > -- > 2.34.1 > >