I found how to solve my problem. I share the solution for other people running into the same error.
The error can be eliminated by using coder.varsize inside the file "call_my_sum.m":
function out = call_my_sum(mat)
%#codegen
coder.varsize('mat', [inf, inf], [1 1]);
assert(isa(mat, 'double'));
if coder.target('MATLAB')
out = call_my_sum_mex(mat);
else
[rows, cols] = size(mat);
out = double(0);
out = coder.ceval('my_sum', coder.ref(mat), rows, cols);
end