Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3432435rdb; Wed, 13 Sep 2023 11:50:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGM8RsVjBpAs/kdmKRoyt1MHBHqjnlqeWNJYAJPZAqY0G7DSuqprsSX64lugzagbKkjDYyY X-Received: by 2002:a17:903:1cc:b0:1c3:aef9:872e with SMTP id e12-20020a17090301cc00b001c3aef9872emr3212966plh.34.1694631004575; Wed, 13 Sep 2023 11:50:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694631004; cv=none; d=google.com; s=arc-20160816; b=jU3JUmJ+k05ps5IBRoaj0kCPAWWiUnog87rW+Fmd6Yt5S+r93kYiN8h33dxPrAWCTR 3IN9O2dfUcJqUFLZ2uws7KOmrpwswtb7mrmJJg+JDoDm2zVbt4LLehaF9suO9nJfyqYn txFNeKmOb0ON6SIDk95GDHSYM6t4A9VsZW8Dr8vi/M962v1wEK434aiv4al+okQxUfPH Jw9Ia6hOebb7sxGac1e0QYdcwMw6WQoNBYuDngpNgjHgRDzio53NWK/CIfyWhk6LfoSm Wob5EHZArKNMX50F83+4B7jAyGDI6oF4csNkD3+VUj3x+5BmZs15k6A5uMz87UCfMSWt VAYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=x+9MtCGEueIzcQpF/feyfAWnqDz9Etq09hyqW4Rc828=; fh=G1JxGbi+2ATuiSNLGy5Ukoby42wPT92H5IrRE+3uXro=; b=MwWcfwVKiUiVMc5AaLmE89/w+u06R6bK8KqOnboazZ4YPD8JQF8MQIYp+PdNT4PD95 M48jnxn6iZtC5NanIIwPXUp4McIDO7VAl6iLpyLYYgfky5Jt/XBOIxsfgRthRdte9iOB kRY/cqjvBpZ9OZCk8bjJmTP/fLEk8bM4/bS49Wc+iK546q2grvW36AGUIaMvH9yU011B L6u47TZSUbo1x/BUIM6sDLtA+72U0J7MH0w472BZwzhrhDfqVRlP8IzYzrHgYyQg82oP j0az34VP5ADlYby5sbPBbnHRITswtQ1Qd/hQYC4P80GYuUR2qlBKqtsvoXSeeojvPXxI ac9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=CUziXbox; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id x15-20020a170902a38f00b001bc434b9d95si7442490pla.156.2023.09.13.11.50.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 11:50:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=CUziXbox; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 2D8B380AB5B1; Wed, 13 Sep 2023 05:37:10 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240625AbjIMMhE (ORCPT + 99 others); Wed, 13 Sep 2023 08:37:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240671AbjIMMhC (ORCPT ); Wed, 13 Sep 2023 08:37:02 -0400 Received: from mail-qk1-x72c.google.com (mail-qk1-x72c.google.com [IPv6:2607:f8b0:4864:20::72c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C5651BC7 for ; Wed, 13 Sep 2023 05:36:58 -0700 (PDT) Received: by mail-qk1-x72c.google.com with SMTP id af79cd13be357-76dcf1d8957so416936585a.1 for ; Wed, 13 Sep 2023 05:36:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1694608617; x=1695213417; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=x+9MtCGEueIzcQpF/feyfAWnqDz9Etq09hyqW4Rc828=; b=CUziXboxV4nwEAAXEV3v0b+3PiIKWbY1l6afchqbO8zc/CsHUs2BvM8LoUzagcgCqL xOqrHoEtDMEztkvBSA4hUx4cYlDeNZ+Gb1km/02+g0dUZ9KDRmgp5zu/HZJo24k3ZUNn 1Sjq+NHwOeLpvDql0g/dSjGNCiypX36qBM+d2wp3DBsVYR3ssOI9aDsvdsheuWV1q9N4 3enfHfjPNyT0KiV603VJTljcMBV9UTJ64N0toTmtGvkzZIBuA2Qoog5fuU0OOivmo+/4 utux3/SUCNH2Axu0T4IJZkfBXIJdkB+CDc0qladQD7fyohX9L3uol8ny8OTlwCf6Eg5P Tfdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694608617; x=1695213417; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=x+9MtCGEueIzcQpF/feyfAWnqDz9Etq09hyqW4Rc828=; b=MrZulBkHPHsIxHyX4p+XyizKCEmIP0+w/3KRFBSkkbbhr+YmT6o5Zz6VCvPWc/zRfR 5hY4mmWSNdYeOkpisFq6uNBYkxN33VXY0eBn3YOMkNhWGUNlevcgPNgjV+5PokfOk2tL 7wBwcri9Mc1Ea/0S4k3hNY2Luj08OIhCfrQpnwBT9/sNnX1OLiASStdAElmoDSX0S4GU VZ2MgKXQssM+43LnLiaORH/LHQXjavVyiUcNp/D/YVdG/wQA1eDSUC49WdDAKErdanI1 2jeuMhkAgwUNzc2jJDmhPdaD9sLAsHoGkNsZbdNkLJzL7MWG4UO3uOEPPFpME4vTBSbF lrMA== X-Gm-Message-State: AOJu0YxPufTiRN1G6sBH82iir/OcOVCKcmiNHoMwqCchKEvfCXPZY8qZ FtwYkIKlb9vdOPBHE7t3qDS44g== X-Received: by 2002:a05:620a:3881:b0:76e:e352:667a with SMTP id qp1-20020a05620a388100b0076ee352667amr1775918qkn.35.1694608617245; Wed, 13 Sep 2023 05:36:57 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-134-41-202-196.dhcp-dynamic.fibreop.ns.bellaliant.net. [134.41.202.196]) by smtp.gmail.com with ESMTPSA id o14-20020ae9f50e000000b0076cdb0afbc4sm3870133qkg.118.2023.09.13.05.36.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 05:36:56 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.95) (envelope-from ) id 1qgP72-002Rzs-3w; Wed, 13 Sep 2023 09:36:56 -0300 Date: Wed, 13 Sep 2023 09:36:56 -0300 From: Jason Gunthorpe To: Cong Liu Cc: alex.williamson@redhat.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] fix build error in function vfio_combine_iova_ranges Message-ID: References: <20230911124431.5e09f53b.alex.williamson@redhat.com> <20230912010736.19481-1-liucong2@kylinos.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230912010736.19481-1-liucong2@kylinos.cn> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Wed, 13 Sep 2023 05:37:10 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email On Tue, Sep 12, 2023 at 09:07:36AM +0800, Cong Liu wrote: > when compiling with smatch check, the following errors were encountered: > > drivers/vfio/vfio_main.c:957 vfio_combine_iova_ranges() error: uninitialized symbol 'last'. > drivers/vfio/vfio_main.c:978 vfio_combine_iova_ranges() error: potentially dereferencing uninitialized 'comb_end'. > drivers/vfio/vfio_main.c:978 vfio_combine_iova_ranges() error: potentially dereferencing uninitialized 'comb_start'. > > this patch fix these error. > > Signed-off-by: Cong Liu > --- > drivers/vfio/vfio_main.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/vfio/vfio_main.c b/drivers/vfio/vfio_main.c > index 40732e8ed4c6..68a0a5081161 100644 > --- a/drivers/vfio/vfio_main.c > +++ b/drivers/vfio/vfio_main.c > @@ -938,12 +938,13 @@ static int vfio_ioctl_device_feature_migration(struct vfio_device *device, > void vfio_combine_iova_ranges(struct rb_root_cached *root, u32 cur_nodes, > u32 req_nodes) > { > - struct interval_tree_node *prev, *curr, *comb_start, *comb_end; > + struct interval_tree_node *prev, *curr; > + struct interval_tree_node *comb_start = NULL, *comb_end = NULL; > unsigned long min_gap, curr_gap; > > /* Special shortcut when a single range is required */ > if (req_nodes == 1) { > - unsigned long last; > + unsigned long last = 0; > > comb_start = interval_tree_iter_first(root, 0, ULONG_MAX); > curr = comb_start; These are not possible unless the list is empty, and assigning zero/null isn't an improvement for that case it will just crash Jason