Don’t forget that the diminutive ending does not depend on the word’s gender, only on its final vowel. Let’s look at an example of a case that might be confusing.
In Brazilian Portuguese, most words ending with -o are masculine and those ending with -a are feminine. However, sometimes the ending can be deceiving. For instance, in the sentence, what is the gender of cinema in: O cinema está lotado de gente(The cinema is full of people)?
As it turns out, cinema is a masculine word, even though it ends with -a! We can tell because it is accompanied by the o, which is only used for masculine words.
But when you are adding a diminutive ending, what matters is not the gender, but the final vowel. Because cinema ends with -a, it still takes the diminutive ending -inha, instead of -inho. So, the diminutive of o cinema is o cineminha. Notice that, just like the base word, this diminutive form is still masculine!
If you want to know more about noun gender in Brazilian Portuguese, take a look at this post.