[13/16] mem/shmem: Use xrealloc_safe in expand_shmem

Submitted by Cyrill Gorcunov on July 5, 2019, 3:38 p.m.

Details

Message ID 20190705153811.22652-14-gorcunov@gmail.com
State Accepted
Series "mem: Cleanup and fixups"
Headers show

Commit Message

Cyrill Gorcunov July 5, 2019, 3:38 p.m.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
 criu/shmem.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/shmem.c b/criu/shmem.c
index 03b088f268a9..da9242674291 100644
--- a/criu/shmem.c
+++ b/criu/shmem.c
@@ -197,8 +197,7 @@  static int expand_shmem(struct shmem_info *si, unsigned long new_size)
 
 	BUG_ON(new_map_size < map_size);
 
-	si->pstate_map = xrealloc(si->pstate_map, new_map_size);
-	if (!si->pstate_map)
+	if (xrealloc_safe(&si->pstate_map, new_map_size))
 		return -1;
 	memzero(si->pstate_map + nr_map_items, new_map_size - map_size);
 	return 0;

Comments

Mike Rapoport July 8, 2019, 5:07 p.m.
On Fri, Jul 05, 2019 at 06:38:08PM +0300, Cyrill Gorcunov wrote:
> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>

Reviewed-by: Mike Rapoport <rppt@linux.ibm.com>

> ---
>  criu/shmem.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/criu/shmem.c b/criu/shmem.c
> index 03b088f268a9..da9242674291 100644
> --- a/criu/shmem.c
> +++ b/criu/shmem.c
> @@ -197,8 +197,7 @@ static int expand_shmem(struct shmem_info *si, unsigned long new_size)
>  
>  	BUG_ON(new_map_size < map_size);
>  
> -	si->pstate_map = xrealloc(si->pstate_map, new_map_size);
> -	if (!si->pstate_map)
> +	if (xrealloc_safe(&si->pstate_map, new_map_size))
>  		return -1;
>  	memzero(si->pstate_map + nr_map_items, new_map_size - map_size);
>  	return 0;
> -- 
> 2.20.1
> 
> _______________________________________________
> CRIU mailing list
> CRIU@openvz.org
> https://lists.openvz.org/mailman/listinfo/criu
>