From: Jason Gunthorpe <jgg@ziepe.ca>
To: Cong Liu <liucong2@kylinos.cn>
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
Date: Wed, 13 Sep 2023 09:36:56 -0300 [thread overview]
Message-ID: <ZQGs6F5y3YzlAJaL@ziepe.ca> (raw)
In-Reply-To: <20230912010736.19481-1-liucong2@kylinos.cn>
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 <liucong2@kylinos.cn>
> ---
> 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
next prev parent reply other threads:[~2023-09-13 12:37 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-11 9:41 Cong Liu
2023-09-11 18:44 ` Alex Williamson
2023-09-12 1:07 ` Cong Liu
2023-09-13 12:36 ` Jason Gunthorpe [this message]
2023-09-14 9:08 ` [PATCH v2] vfio: Fix uninitialized symbol and potential dereferencing errors in vfio_combine_iova_ranges Cong Liu
2023-09-19 18:04 ` Alex Williamson
2023-09-20 9:55 ` [PATCH v3] " Cong Liu
2023-10-02 22:41 ` Alex Williamson
2023-10-02 22:43 ` [PATCH] vfio: Fix smatch errors in vfio_combine_iova_ranges() Alex Williamson
2023-10-04 15:35 ` Brett Creeley
2023-10-06 16:56 ` Jason Gunthorpe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZQGs6F5y3YzlAJaL@ziepe.ca \
--to=jgg@ziepe.ca \
--cc=alex.williamson@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liucong2@kylinos.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®