OSDN Git Service

Drivers: hv: hv_balloon: correctly handle num_pages>INT_MAX case
authorVitaly Kuznetsov <vkuznets@redhat.com>
Tue, 31 Mar 2015 18:16:41 +0000 (11:16 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 3 Apr 2015 14:20:12 +0000 (16:20 +0200)
commit797f88c987b02a8de8d4fac94ec2877b92ec35a2
treea4bb69aa6bab4b4af5778bb59e94bfcd68aa138f
parentba0c444153889a9b672974d85a4a57a8eeb49fe3
Drivers: hv: hv_balloon: correctly handle num_pages>INT_MAX case

balloon_wrk.num_pages is __u32 and it comes from host in struct dm_balloon
where it is also __u32. We, however, use 'int' in balloon_up() and in case
we happen to receive num_pages>INT_MAX request we'll end up allocating zero
pages as 'num_pages < alloc_unit' check in alloc_balloon_pages() will pass.
Change num_pages type to unsigned int.

In real life ballooning request come with num_pages in [512, 32768] range so
this is more a future-proof/cleanup.

Reported-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/hv/hv_balloon.c