cudaMemcpy failing for me with cudaErrorInvalidValue

I have a complicated way of filling in an array and copying it back to the host:

int averages[256];
	void *devptr;
	int *average_array;
	cudaError_t rc;

	rc = cudaGetSymbolAddress(&devptr,PixelAverages);
	if (rc != cudaSuccess) {
		return -1;
		}
	rc = cudaMalloc(&average_array,sizeof *PixelAverages * 256);
	if (rc != cudaSuccess) {
		return -1;
		}
	rc = cudaMemcpy(devptr,&average_array,sizeof average_array,cudaMemcpyHostToDevice);
	if (rc != cudaSuccess) {
		cudaFree(average_array);
		return -1;
		}

	memset(&averages,0,sizeof averages);
	rc = cudaMemcpy(average_array,&averages,sizeof averages,cudaMemcpyHostToDevice);
	if (rc != cudaSuccess) {
		cudaFree(average_array);
		return -1;
		}

This works fine, but seems like a lot of complexity in allocating the array dynamically. It would seem that the following should work as well, but the cudaMemcpy fails with cudaErrorInvalidValue:

memset(diffs,0,sizeof diffs);
	rc = cudaGetSymbolAddress(&d_pixeldiffs,PixelDiffs);
	if (rc != cudaSuccess) {
		return -1;
		}
	rc = cudaMemcpy(d_pixeldiffs,&diffs,sizeof diffs,cudaMemcpyHostToDevice);
	if (rc != cudaSuccess) {
		return -1;
		}

I have also tried using cudaMemcpyToSymbol and is consistently fails as well - it would seem to be a better alternative than cudaGetSymbolAddress and cudaMemcpy but I must be missing something important with it. Any symbol name in quotes fails because it isn’t known, and attempting to reference a device variable also fails.

Before it gets here there is a lot going on, such as the first block of code. It get all the way to this function under Nsight and this is the first exception thrown under the VS debugger.

Any suggestions?

Not sure why I didn’t see it, but the definition of PixelDiffs was incorrect. The second form is working now. What a difference a weekend makes!