Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1579351rwb; Sun, 18 Sep 2022 09:54:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7y+OjHXJ/LL0BnS40sQhayTu2voLgWyHrHyl2SGtWv7Pdvbz4PorA/lO8llV7TBsD3d6qY X-Received: by 2002:a05:6a00:1a44:b0:528:6af7:ff4a with SMTP id h4-20020a056a001a4400b005286af7ff4amr15091137pfv.78.1663520062924; Sun, 18 Sep 2022 09:54:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663520062; cv=none; d=google.com; s=arc-20160816; b=XaKTxqLAGVY+wclw7o0RzpIgViCdHbR2Ib48KoZOUF8ZFtvAa5zZzM2vPZ41lXdN4H /KGRZn0MwX0G0ltO+GnfcDSkCATuX1tPrDMBea5VoX/8sCqRS1Rk5bbGLj86W8U77/z9 Ycv1qShh8SaEfdp1+N2Z0cYWbP9rEvzln6ZtEwu+unTMLE27KOGx+RWCx7vKEqB3Gppq mcUqbNGfMRlr76LnPwezDwVFs0SHz6DIWmgF0h32FXPYNBioc1yCPuAfsauAahBjbyGQ ahFaTpznmxzkHLqmdIfQkM/ZFIY5wganN/mNkeec7+0Akj0MnotiPQMuZC3iqFvswfsK Byag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=ODbIQU9597VA/Wq31XH7ZTVJyvSErs3yWMdjJTILVD0=; b=GkpTbn+WAWpQUVib/ZoP5QMMPvtYiQ1TV7pYKPNhRj1OBf1LA9gad83AVLdx/1DrSu Pm3ZmDUAwdm+KVUXNdLhJ5j76xUdqglhvKorKpTNfHhUKeKsaZui6YPnmr2PsusyJRtR OtuLWYfA+05UYsEBQM3dPFeOdcyBMrfekZvWcDsSIy6t6tx+FqP1WOTSlqqHppiI+TII hgNGcMQYncz1zRd6U7+aUHos/biNo8Njjb26DxNZb1j34P5M5a0O/7q6drZ42/lu8sCZ kLdzmGfTEOxXxD1pjL+7hDL1PuVAF2fHmhPBF3wYvp0HLWSTdT/Z+Ad/EeVufEvOm4hT KqeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=X2+Dkm7G; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a23-20020a63d217000000b004396227b476si15659613pgg.774.2022.09.18.09.54.11; Sun, 18 Sep 2022 09:54:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=X2+Dkm7G; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229676AbiIRQWX (ORCPT + 99 others); Sun, 18 Sep 2022 12:22:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229779AbiIRQWW (ORCPT ); Sun, 18 Sep 2022 12:22:22 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31CBACE07 for ; Sun, 18 Sep 2022 09:22:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663518140; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ODbIQU9597VA/Wq31XH7ZTVJyvSErs3yWMdjJTILVD0=; b=X2+Dkm7GLX2ZUFpGarFpOUXONHwaEsOf8GCzR5OgJniz8Fueik2H2UJ8ScssgmUNtt7uPq GtaMPzYwxy0HBzm2Wq/vI3F5PbctOmoRASuUpYwOQbMgfeNGQH3k1C7jQ0gu7lSsPh9oCw zvDx5TS5LZQWoLkRg7TlrQQCz4qFOWo= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-320-ahqmzYSUPneThVo4_PSPXQ-1; Sun, 18 Sep 2022 12:22:18 -0400 X-MC-Unique: ahqmzYSUPneThVo4_PSPXQ-1 Received: by mail-qk1-f200.google.com with SMTP id u20-20020a05620a455400b006ce5151968dso16182398qkp.11 for ; Sun, 18 Sep 2022 09:22:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date; bh=ODbIQU9597VA/Wq31XH7ZTVJyvSErs3yWMdjJTILVD0=; b=EodEpqM20xcKcQKzQilHOxDnPrOqXO+doJFkZenFrJS6wJlvaUfHKQGWokDNPuvuUx HDD8OwtiOp1H3oWEefW7bfTz8U32jaJvtOCDsz7MAPKwLs9F/gy+G6oxmp4DNJjLWQpx rfmJj2VveKsSI/1knK0DzcTR+y20bx7haprOwKczpJhPQxwxA5Ow1z8trcVo5NQO5c+w 0GLQdu5euszdYp71RIX33zOvbLmoxAkiasifaQeSP5K4L5kUOKtoSZMGFEBrIAPXaC+m 8SVXPLfHUvapSuX5OfquJeSRaDh0bXVs93SAL/OJeIAlgrAPJaca7p6cOVXAsMWlfLVB uusg== X-Gm-Message-State: ACrzQf3VSnDTodGas1L9ERiRy0+xHpcfp/G4Fb7+toeyY38JTakJ/+vB P+AHnC05gfdAsqZFxIh+rmB2IzodtRvCpwloJH0u1b4yIkRGZii1NFvQCHW4ppnxMYCrkPbxPSq CZruh5sxJK7Zq+3npS/gpWL55 X-Received: by 2002:ad4:5aaf:0:b0:4a8:a817:e00d with SMTP id u15-20020ad45aaf000000b004a8a817e00dmr11896907qvg.18.1663518138143; Sun, 18 Sep 2022 09:22:18 -0700 (PDT) X-Received: by 2002:ad4:5aaf:0:b0:4a8:a817:e00d with SMTP id u15-20020ad45aaf000000b004a8a817e00dmr11896890qvg.18.1663518137931; Sun, 18 Sep 2022 09:22:17 -0700 (PDT) Received: from ?IPV6:2a04:ee41:4:31cb:e591:1e1e:abde:a8f1? ([2a04:ee41:4:31cb:e591:1e1e:abde:a8f1]) by smtp.gmail.com with ESMTPSA id w16-20020a05620a425000b006b9c9b7db8bsm11592922qko.82.2022.09.18.09.22.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 18 Sep 2022 09:22:17 -0700 (PDT) Message-ID: Date: Sun, 18 Sep 2022 18:22:12 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Subject: Re: [RFC PATCH 5/9] kvm_main.c: split __kvm_set_memory_region logic in kvm_check_mem and kvm_prepare_batch Content-Language: en-US To: "Yang, Weijiang" Cc: Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , David Hildenbrand , Maxim Levitsky , x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org, "kvm@vger.kernel.org" References: <20220909104506.738478-1-eesposit@redhat.com> <20220909104506.738478-6-eesposit@redhat.com> <9fcd1d25-ec4d-eebe-623f-cfeb48b6656f@intel.com> From: Emanuele Giuseppe Esposito In-Reply-To: <9fcd1d25-ec4d-eebe-623f-cfeb48b6656f@intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am 13/09/2022 um 04:56 schrieb Yang, Weijiang: > > On 9/9/2022 6:45 PM, Emanuele Giuseppe Esposito wrote: >> Just a function split. No functional change intended, >> except for the fact that kvm_prepare_batch() does not >> immediately call kvm_set_memslot() if batch->change is >> KVM_MR_DELETE, but delegates the caller (__kvm_set_memory_region). >> >> >> +static int kvm_check_memory_region(struct kvm *kvm, >> +                const struct kvm_userspace_memory_region *mem, >> +                struct kvm_internal_memory_region_list *batch) >> +{ >> +    int r; >> + >> +    r = check_memory_region_flags(mem); >> +    if (r) >> +        return r; >>   -    r = kvm_set_memslot(kvm, batch); >> +    r = kvm_check_mem(mem); >>       if (r) >> -        kfree(new); >> +        return r; >> + >> +    r = kvm_prepare_batch(kvm, mem, batch); >> +    if (r && batch->new) >> +        kfree(batch->new); > From the patch, r !=0 and batch->new !=NULL are exclusive, so free() > here is not reachable. Good point, I'll get rid of this. Thank you, Emanuele >> + >>       return r; >>   } > [...] >>   >