How to use "NvBufSurfaceCreate“ and "NvBufSurfaceCopy" to copy another device surface?

my code is:
NvBufSurfaceCreateParams param = {0};
param.gpuId = ip_surf->gpuId;
param.width = ip_surf->surfaceList[0].width;
param.height = ip_surf->surfaceList[0].height;
param.colorFormat = ip_surf->surfaceList[0].colorFormat;
param.layout = ip_surf->surfaceList[0].layout;
//param.isContiguous = 0;
param.memType = ip_surf->memType;
param.size = ip_surf->surfaceList[0].dataSize;

NvBufSurface *ip_surf_new;
if(NvBufSurfaceCreate(&ip_surf_new, ip_surf->numFilled, &param)){
GST_CAT_DEBUG (NVDS_APP, “Fail to create surface, mem type = %d”,ip_surf->memType);
return;
}
ip_surf_new->batchSize = ip_surf->batchSize;
ip_surf_new->numFilled = ip_surf->numFilled;
ip_surf_new->memType = ip_surf->memType;
for (int i=0; i < ip_surf_new->batchSize; i++) {
ip_surf_new->surfaceList[i].dataSize = ip_surf->surfaceList[i].dataSize;
}
if (NvBufSurfaceCopy (ip_surf, ip_surf_new) != 0) {
GST_CAT_DEBUG (NVDS_APP, “Fail to copy surface, mem type = %d”,ip_surf->memType);
return;
}
copy failed because of “mismatch buffer size”, there is something wrong this code?