Technically speaking, the EF 40mm f2.8 is neither a macro lens nor a portrait lens in the traditional sense. It can be used for those purposes, though it might not be my top choice for either one. I'll suggest some alternatives.
You don't mention which Canon DSLR you bought, and that can make some difference how a lens will perform or what lens to recommend.
So I'm going to assume it's one of the "crop sensor" models: 7D, 70D, 60D, T5i/700D, T4i/650D, T3i/600D, SL1/100D or T3/1100D. These are the bulk of what people buy and Canon sells.
If you want a lens that can do both macro and portraiture, there are several ways to achieve that.
If you mostly want to do macro photography and portraits are a somewhat secondary purpose, I'd recommend one of the true macro lenses. The Canon EF-S 60mm f2.8 USM Macro is an excellent choice. There is also the Tamron SP 60mm f2.0, which is a full stop faster and might be nicer for portraiture since it can blur down backgrounds more. The Tamron is not nearly as fast focusing as the Canon, however. Note that both these are "crop only" lenses, will not work on "full frame cameras" (6D, 5D Mark III, 1DX). Both offer full 1:1 macro capability and are internal focusing (IF), which means they don't increase in length when focused closer.
Another possibility is the older Canon EF 50mm f2.5 Compact Macro. This is a 1:2 lens on it's own, but can be fitted with an optional adapter to be able to shoot full 1:1 magnification. Alternatively, it could be used with a macro extension tube or two, to increase it's magnification capabilities. As an EF lens, this can be used on either a crop camera or on full frame. In my opinion, it would be a bit short for some macro work, especially on a full frame camera. But it's a good focal length for general portraiture work.
There are other, longer macro focal lengths that can serve dual purpose for portraiture. However, they might be too long for indoor portraiture, if working space is tight... especially when used on a crop camera. They include the Canon 100mm f2.8 USM and 100mm f2.8L IS USM macro lenses. There are also Sigma 70mm f2.8, Tamron SP 90mm f2.8, Tamron SP 90mm f2.8 VC USD, Tokina AT-X 100/2.8 and Sigma 105mm f2.8 OS HSM. All these will work fine on either crop or full frame DSLRs. However, again, they are starting to be a little long for some portraiture, though they might give better working distance for a lot of macro shooting.
I should also note that the Canon mid-range zooms all tend to be pretty close focusing, too... even if not quite "true" macro. The EF 24-70/2.8L gives the closest focus and highest magnification, but also is the priciest of the bunch. However, I really like it for portraiture on a crop camera (it can be a little short for portraiture on FF, IMO). EF 28-135mm, EF 24-105mm, EF-S 18-135mm, EF-S 18-55mm and EF-S 15-85mm are all fairly close focusing, too, though none of them are "true" macro lenses. Any of the Canon EF 70-200mm lenses might be used too.
All these non-macro zooms, plus some nice portrait primes such as the EF 50/1.4, EF 50/1.8 and EF 85/1.8 also can be made to focus closer for occasional macro shots, by fitting them with macro extension tubes. I recommend either the Canon or the Kenko extension tubes... the Canon sell individually in 12mm and 25mm lengths, while Kenko offers a set that includes 12mm, 20mm and 36mm.... the latter is generally a better value and can more versatile.
If your primary use were portraits, only occasionally wanted to take some macro shots, you might want to consider using one of these non-macro lenses with some extension tubes.
IMO the EF 40mm f2.8 lens' primary appeal is it's ultra compact size. It would be a great travel lens. For macro, I'd find the focal length too short a lot of the time, even if it were made to be closer focusing by adding some macro extension tubes. I'd also find it a bit short for portraiture... and would prefer a larger aperture a lot of the time for that purpose. For me a 50mm to 100mm lens seems more ideal. I've been using the Canon 50/1.4, 85/1.8 and 135/2 (the last on FF mostly) for portraiture, and occasionally with extension tubes for near-macro, close-up shots. Some true macro lenses I use include the Canon 100/2.8 USM and Tamron 90mm. Just recently I've also been trying out the Tamron 60/2.0 Macro/Portrait lens. As to zooms, I use the 24-70 and a couple 28-135s, along with a couple 70-200s. All are good for portraits, and I've occasionally used them with macro extension tubes, too.
This was shot with 70-200/2.8 IS with 25mm macro extension tube (in this case on full frame, a film camera in fact)...
This was shot with EF 50mm f1.4 lens with 12mm extension tube added (on a crop camera, 10D)...
This was shot with EF 24-70/2.8 without any extension tubes, near it's closest focus (on crop camera, 7D)...
This was shot with Canon EF 100mm f2.8 USM macro lens (on crop camera, 30D)...
And this was shot with Tamron 90mm f2.8 macro lens (a vintage, manual focus lens adapted for use on Canon, in this case a 7D)...
As to portraiture, this was shot with an EF 85/1.8 on a crop camera (30D)...
And this with EF 50/1.4, also on a crop camera (30D)...
And this is using EF 70-200/2.8 IS at a fairly long focal length (160mm), still on a crop camera (30D)....
And this was shot with EF 70-200/4 IS at a fairly short focal length (93mm, on 7D)...
So there are lot's of possibilities! Which would be best choice for you sort of depends upon what your priorities are, how much you want to spend, how big/heavy a lens you are willing to haul around, and what other lenses you might already have in your tool kit.
I don't have any shots online made with the Tamron 60/2 Macro/portrait yet... I got that lens in hopes of having one reasonably compact lens do the work of three (50/1.4, 85/1.8 and a macro lens) to help lighten my load at times... such as when I'm out shooting other stuff and don't really know if I'll need to grab a portrait or macro shot. So far it's served well for more sedate shooting, but it's not fast enough focusing to keep up with any sort of action/sports (most true macro lenses will struggle with faster action and AI Servo tracking.... simply because most true macro lenses emphasize focusing accuracy over speed).
Hope this helps!
09/26/2023: New firmware updates are available.
08/18/2023: Canon EOS R5 C training series is released.
07/31/2023: New firmware updates are available.
05/31/2023: New firmware updates are available.
05/18/2023: New firmware updates are available.
03/30/2023: New firmware updates are available.