Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751815AbdHCNFX (ORCPT ); Thu, 3 Aug 2017 09:05:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:27944 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751677AbdHCNFV (ORCPT ); Thu, 3 Aug 2017 09:05:21 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 84C26356CC Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=pagupta@redhat.com Date: Thu, 3 Aug 2017 09:05:06 -0400 (EDT) From: Pankaj Gupta To: Wei Wang Cc: linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, kvm@vger.kernel.org, linux-mm@kvack.org, mst@redhat.com, mhocko@kernel.org, mawilcox@microsoft.com, akpm@linux-foundation.org, virtio-dev@lists.oasis-open.org, david@redhat.com, cornelia huck , mgorman@techsingularity.net, aarcange@redhat.com, amit shah , pbonzini@redhat.com, liliang opensource , yang zhang wz , quan xu Message-ID: <900253471.38532197.1501765506419.JavaMail.zimbra@redhat.com> In-Reply-To: <598316DB.4050308@intel.com> References: <1501742299-4369-1-git-send-email-wei.w.wang@intel.com> <1501742299-4369-6-git-send-email-wei.w.wang@intel.com> <147332060.38438527.1501748021126.JavaMail.zimbra@redhat.com> <598316DB.4050308@intel.com> Subject: Re: [PATCH v13 5/5] virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_VQ MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.116.55, 10.4.195.18] Thread-Topic: virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_VQ Thread-Index: i+k18WXEwBcRKATubiCyxylnK34NVw== X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 03 Aug 2017 13:05:20 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1633 Lines: 59 > > On 08/03/2017 04:13 PM, Pankaj Gupta wrote: > >> > >> + /* Allocate space for find_vqs parameters */ > >> + vqs = kcalloc(nvqs, sizeof(*vqs), GFP_KERNEL); > >> + if (!vqs) > >> + goto err_vq; > >> + callbacks = kmalloc_array(nvqs, sizeof(*callbacks), GFP_KERNEL); > >> + if (!callbacks) > >> + goto err_callback; > >> + names = kmalloc_array(nvqs, sizeof(*names), GFP_KERNEL); > > > > is size here (integer) intentional? > > > Sorry, I didn't get it. Could you please elaborate more? This is okay > > > > > >> + if (!names) > >> + goto err_names; > >> + > >> + callbacks[0] = balloon_ack; > >> + names[0] = "inflate"; > >> + callbacks[1] = balloon_ack; > >> + names[1] = "deflate"; > >> + > >> + i = 2; > >> + if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_STATS_VQ)) { > >> + callbacks[i] = stats_request; > > just thinking if memory for callbacks[3] & names[3] is allocated? > > > Yes, the above kmalloc_array allocated them. I mean we have created callbacks array for two entries 0,1? callbacks = kmalloc_array(nvqs, sizeof(*callbacks), GFP_KERNEL); But we are trying to access location '2' which is third: i = 2; + if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_STATS_VQ)) { + callbacks[i] = stats_request; <---- callbacks[2] + names[i] = "stats"; <----- names[2] + i++; + } I am missing anything obvious here? > > > Best, > Wei >