cudaMemcpy2D Bus error

I’m trying to copy an array of numObjs * numCoords float elements from the host to the device. I have tried the following code but when I try to run it says me “Bus Error”. The problem is with cudaMemcpy2D because i added a printf after cudaMallocPitch and it was executed successfully. The checkCUDAError is a simple function which takes the last error from Cuda. objects is allocated with malloc and is filled with data in another file.

/* allocate memory at the device ----------------------------------------*/

cudaMallocPitch((void **) &dev_objects, &obj_pitch, numObjs * sizeof(float), numCoords);

/* copy memory form host to device ------------------------------------*/

cudaMemcpy2D(dev_objects, obj_pitch, *objects, numObjs * sizeof(float), numObjs * sizeof(float), numCoords, cudaMemcpyHostToDevice);

checkCUDAError("cudaMemcpy calls");

Can anyone help?