Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754615AbcDKTwY (ORCPT ); Mon, 11 Apr 2016 15:52:24 -0400 Received: from mail-wm0-f45.google.com ([74.125.82.45]:34600 "EHLO mail-wm0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754403AbcDKTwW (ORCPT ); Mon, 11 Apr 2016 15:52:22 -0400 From: Rasmus Villemoes To: Sudip Mukherjee Cc: Mike Snitzer , Alasdair Kergon , Shaohua Li , linux-kernel@vger.kernel.org, dm-devel@redhat.com, linux-raid@vger.kernel.org Subject: Re: dm: ioctl: use kvfree Organization: D03 References: <1460387677-19948-1-git-send-email-sudipm.mukherjee@gmail.com> <20160411151714.GB25938@redhat.com> <570BCC51.50004@gmail.com> X-Hashcash: 1:20:160411:agk@redhat.com::TytWGJTCY1ZscNPG:0000EKg X-Hashcash: 1:20:160411:sudipm.mukherjee@gmail.com::8S2U5pBU4XXTKeqQ:000000000000000000000000000000000000Y2N X-Hashcash: 1:20:160411:snitzer@redhat.com::EI3PAl1/oPF497S7:00000000000000000000000000000000000000000000qkA X-Hashcash: 1:20:160411:dm-devel@redhat.com::iDjvwlnXtwCG6ZI6:0000000000000000000000000000000000000000001/OA X-Hashcash: 1:20:160411:linux-kernel@vger.kernel.org::cB6Afg7/qnzgGdK0:0000000000000000000000000000000007H5s X-Hashcash: 1:20:160411:linux-raid@vger.kernel.org::DqYOpiHteVdD9eNW:000000000000000000000000000000000005C7u X-Hashcash: 1:20:160411:shli@kernel.org::LBfOI4rVhACAI2Bl:007hsw Date: Mon, 11 Apr 2016 21:52:18 +0200 In-Reply-To: <570BCC51.50004@gmail.com> (Sudip Mukherjee's message of "Mon, 11 Apr 2016 21:39:53 +0530") Message-ID: <87wpo3q5xp.fsf@rasmusvillemoes.dk> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1262 Lines: 34 On Mon, Apr 11 2016, Sudip Mukherjee wrote: > On Monday 11 April 2016 08:47 PM, Mike Snitzer wrote: >> On Mon, Apr 11 2016 at 11:14am -0400, >> Sudip Mukherjee wrote: >> >>> We can use kvfree() instead of calling kfree() and vfree() based on >>> if-else and param_flags. kvfree() will check the type of address and >>> will call the respective function to free it. >>> Additionally we can also remove the use of DM_PARAMS_KMALLOC and >>> DM_PARAMS_VMALLOC. >>> >>> Signed-off-by: Sudip Mukherjee >> >> Have you actually tested htis? Last time I looked to do this it exposed >> crashes. I don't have time to dig into this again right now but this is >> _not_ as simple as this patch implies. >> > > No, it was just build tested. Is it possible to test it in qemu or kvm? > No need to test it, just read copy_params() and its caller, ctl_ioctl(). The latter passes a stack buffer as param_kernel, and copy_params() does if (ioctl_flags & IOCTL_FLAGS_NO_PARAMS) { dmi = param_kernel; with dmi later returned via *param. So it is entirely possible that free_params ends up calling neither kfree or vfree, since there's nothing to free. Rasmus