Dee, do you really mean that the smell comes FROM the fan, or there is a smell when the fan is running?
The fan should be in the ceiling blowing up and out, so no smell should be coming from that (not to mention a fan just shouldn't smell like that).
However if you flush when the fan is running it can draw stinky air up through the toilet into the room (it's pulling air from the vent on the roof, through the black tank, and into the bathroom). So simply turn off the fan before flushing, and make sure that there is water in the bottom of the toilet at all other times - that will create a seal to keep the stinky air down where it belongs.
You could also be smelling the gray tank through the air admittance valve under the sink (gray tanks can smell as bad as the blank tank).
Under the sink you should see a pipe that's the size as the drain coming from the sink, but this pipe goes straight up towards the bottom of the counter.
At the top of the pipe is something that will look like the item in the link below.
If the little rubber flapper inside that has become stuck or warped it will allow stinky air from the gray tank to be drawn in to the bathroom when the fan is running.
Replacing these is cheap and easy (but not necessarily fun).
There is also one of these at the kitchen sink - just FYI.
https://www.amazon.com/dp/B000KKSP52...a-305607402370