cudaMemcpy3D not working correctly

Hello,

I am trying to copy a matrix to the device memory and then back to the host, in order to check how cudaMemcpy3D and cudamalloc3D work.

My code compiles but I get an erroneous output. Bellow im and images are two 3D int matrices that for which I allocate memory using malloc.

im contains my input and images is blank. The output I get is 0s.

// allocate memory in the device for the images 3D array

	cudaExtent extent1 = make_cudaExtent(n*sizeof(int), m, o);

	cudaPitchedPtr d_im;

	cudaMalloc3D(&d_im, extent1); 			

	

	// copy images to device		

	cudaMemcpy3DParms copyParams = {0};

	copyParams.srcPtr = make_cudaPitchedPtr( (void*) im, m*sizeof(int), n , o);

	copyParams.dstPtr = d_im;

	copyParams.kind = cudaMemcpyHostToDevice;

	copyParams.extent = extent1;

	cudaMemcpy3D(&copyParams);

	//copy data back to host

	cudaMemcpy3DParms copyParams2 = {0};

	copyParams2.dstPtr = make_cudaPitchedPtr( (void*) images, m*sizeof(int), n , o);

	copyParams2.srcPtr = d_im;

	copyParams2.kind = cudaMemcpyDeviceToHost;

	copyParams2.extent = extent1;

	cudaMemcpy3D(&copyParams2);

What do I do wrong?