Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp128607ybg; Mon, 8 Jun 2020 18:26:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3S/QtYBiykhrDItJEY8+z2M0ogCBFEW4GqBSldbHf8j9yjSpbCr/m68bYdBxuLb67UGKs X-Received: by 2002:a50:8467:: with SMTP id 94mr24116059edp.249.1591665991738; Mon, 08 Jun 2020 18:26:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591665991; cv=none; d=google.com; s=arc-20160816; b=wc7PzX/X09nLDD9E5x0AiYHsSqfuYOnS8zDql4QU3bWm7GvFkRpqJ9X1cPxlNHUXFR GbGELY1687akouFhDxaaOzM/DY30ARSVeAoWqL8obWx5dMM3Bo7mBMVgf8gOnLx1Dpx6 Bt2qxZo2vRtLT8jBUPc4BDZXCcZh0BH3OQj2BfP6XANDuIHO8GmoH1hWxS7p2ePPHhiX semre6d9deVcR+ut9LBh2PkmhT41D4JoAV0STBnWZpJv34K+QnN5j4BEJ1jPrcb/pgvq eXLL2dxmq+QumApyjIMGNzRzkT3eM45Le7QBd0vRpFrNvi3oHfkJ6fzSnhF4KLKP53gG kUDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=/lKEeH82FAP2T4Gb2kCeBPUWnj7zsyVaKrTYusWU+6s=; b=v1yZypB8jLjTNd6C2Pa+o/pMwxwpRPpDy8/Oe4eTDedQjn/13LkBJjrhVYdh4dPb+s 1s/oUkWm439Sv/cYIPqHtFq/bsYRLwI9ZHTnsPulkxN+mbN0Esse5PrbVx4Pcb/plTMh YhX4n1+1zkecKs/HEwgLj0pfrlQ2CpB0SboqEHXd9qr/1Yq/lTwjDNhPaKncnqvKhizX r4C0JKqFmZHLgnqHf+r4fxSJmAV2UMF4rpm/nQ+HsM5YEBoDWOnZLENP/Qww45h9/fqW y5dWovXqezarxJr3HlC1TnPEZ6Uh0EyK2VzJXRvRphKSQv40rss77swxjJTlP29w2cXT QmMQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dn17si13116811ejc.556.2020.06.08.18.26.08; Mon, 08 Jun 2020 18:26:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726989AbgFIBWR (ORCPT + 99 others); Mon, 8 Jun 2020 21:22:17 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:60096 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726895AbgFIBWR (ORCPT ); Mon, 8 Jun 2020 21:22:17 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 04AFF35E5A7AEEBD6161; Tue, 9 Jun 2020 09:22:13 +0800 (CST) Received: from [10.134.22.195] (10.134.22.195) by smtp.huawei.com (10.3.19.206) with Microsoft SMTP Server (TLS) id 14.3.487.0; Tue, 9 Jun 2020 09:22:12 +0800 Subject: Re: [PATCH v2] f2fs: use kfree() instead of kvfree() to free superblock data To: Denis Efremov , Jaegeuk Kim CC: , References: <20200605181533.73113-1-efremov@linux.com> <20200608154123.235198-1-efremov@linux.com> From: Chao Yu Message-ID: Date: Tue, 9 Jun 2020 09:22:11 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20200608154123.235198-1-efremov@linux.com> Content-Type: text/plain; charset="windows-1252" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.134.22.195] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Denis, On 2020/6/8 23:41, Denis Efremov wrote: > Use kfree() instead of kvfree() to free super in read_raw_super_block() > because the memory is allocated with kzalloc() in the function. > Use kfree() instead of kvfree() to free sbi in f2fs_fill_super() and > f2fs_put_super() because the memory is allocated with kzalloc(). > > Fixes: 5222595d093e ("f2fs: use kvmalloc, if kmalloc is failed") > Signed-off-by: Denis Efremov I found two missing cases, so how about this? diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index f3c151169542..f913a63e93f0 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -1206,7 +1206,7 @@ static void f2fs_put_super(struct super_block *sb) sb->s_fs_info = NULL; if (sbi->s_chksum_driver) crypto_free_shash(sbi->s_chksum_driver); - kvfree(sbi->raw_super); + kfree(sbi->raw_super); destroy_device_list(sbi); f2fs_destroy_xattr_caches(sbi); @@ -1221,7 +1221,7 @@ static void f2fs_put_super(struct super_block *sb) #ifdef CONFIG_UNICODE utf8_unload(sbi->s_encoding); #endif - kvfree(sbi); + kfree(sbi); } int f2fs_sync_fs(struct super_block *sb, int sync) @@ -3101,7 +3101,7 @@ static int read_raw_super_block(struct f2fs_sb_info *sbi, /* No valid superblock */ if (!*raw_super) - kvfree(super); + kfree(super); else err = 0; @@ -3779,11 +3779,11 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent) #endif kvfree(options); free_sb_buf: - kvfree(raw_super); + kfree(raw_super); free_sbi: if (sbi->s_chksum_driver) crypto_free_shash(sbi->s_chksum_driver); - kvfree(sbi); + kfree(sbi); /* give only one another chance */ if (retry_cnt > 0 && skip_recovery) {