But return_dir is not initialized. Trying to write there is undefined, and can cause real problems.
Once you fix that, I'm not sure what precisely your program is trying to do. But there's an issue with this:
Here you are modifying the string contained in dir. This means you are modifying the original string as passed to the function. An easy way around this is something like:
dir_path = strcat(dir,"/");
dir_path = strcat(dir_path,dp->d_name);
and nothing else inside your if block.
Whether this works depends on your needs.