Roger Federer believes mistakes were made in the handling of Serena Williams' US Open final defeat to Naomi Osaka, but says umpires must be allowed to do their jobs.

American great Williams was beaten in the showpiece match at Flushing Meadows 6-2 6-4 by first-time grand slam winner Osaka in a match that was embroiled in controversy.

Williams was given a code violation for what chair umpire Carlos Ramos deemed to be on-court coaching, something the 23-time grand slam champion vehemently denied, and was later docked a point for smashing her racket. Things then came to a head when Williams angrily confronted Ramos, demanding an apology and branding him a "liar" and a "thief", comments that prompted the official to hand down a game penalty.

In the aftermath of her defeat, Williams claimed that had she been male, she would have been treated more leniently.

ALSO READ | Male tennis players punished more than women

The debate has continued to rumble on and Federer has weighed in on the situation.

"I think it's interesting, because I think it's important to look at. I just think every umpire has their own style, it's just how it is," he said at an event held by the Andy Roddick Foundation in Austin.

"I think in any sport, you know, in tennis you might have an umpire that looks more into giving coaching violations, another guy goes more into time violation, another guy knows this guy misbehaves quite often so I'll give him a warning quicker, or I'll be more lenient with the guy because actually he's a nice guy, he just cannot control himself. 

"I think it really depends on the situation. I hope it's not the case, but I think what happened, especially with the finals, and also with [Alize] Cornet [who was penalised on court for adjusting her shirt], obviously there were mistakes that happened along the way and there should be more discretion used - sometimes.

"At the same time they have to do their job, you know, that's what we also want them to do. So it's been tricky but a really interesting case to study in my opinion."