Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1703101
| From | Wei Wang <wei.w.wang@intel.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v13 5/5] virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_VQ |
| Date | 2017-08-03 15:20 +0200 |
| Message-ID | <uaocG-rc-19@gated-at.bofh.it> (permalink) |
| References | <uai7g-4AX-9@gated-at.bofh.it> <uai7g-4AX-19@gated-at.bofh.it> <uajwm-5IR-15@gated-at.bofh.it> <uanqi-8kg-33@gated-at.bofh.it> <uao32-n3-39@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 08/03/2017 09:05 PM, Pankaj Gupta wrote:
>> 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?
Yes.
if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_STATS_VQ) is true
nvqs will be 3, that is, callbacks[2] is allocated.
Best,
Wei
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v13 5/5] virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_VQ Wei Wang <wei.w.wang@intel.com> - 2017-08-03 08:50 +0200
Re: [PATCH v13 5/5] virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_VQ Pankaj Gupta <pagupta@redhat.com> - 2017-08-03 10:20 +0200
Re: [PATCH v13 5/5] virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_VQ Wei Wang <wei.w.wang@intel.com> - 2017-08-03 14:30 +0200
Re: [PATCH v13 5/5] virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_VQ Pankaj Gupta <pagupta@redhat.com> - 2017-08-03 15:10 +0200
Re: [PATCH v13 5/5] virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_VQ Wei Wang <wei.w.wang@intel.com> - 2017-08-03 15:20 +0200
Re: [PATCH v13 5/5] virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_VQ "Michael S. Tsirkin" <mst@redhat.com> - 2017-08-03 14:40 +0200
csiph-web