Climate change is almost unanimously considered one of the gravest threats facing humanity, with the worst-case scenarios representing massive environmental destruction. Investors hoping to combat it with their portfolio allocations can, but one famous environmentally focused company may actually be doing more harm than good.

Morgan Stanley identified 39 stocks that generate at least half their revenue “from the provision of solutions to climate change,” something it said was a central component of investing to make a difference, as opposed to just a making a buck.

“In our view, impact investing needs to begin with companies whose products and services have a notable positive environmental or social impact,” wrote Jessica Alsford, an equity strategist at the investment bank.

Not surprisingly, alternative-energy companies ranked the highest in terms of their positive impact, and the “top five climate-change impact stocks” were all manufacturers of solar and wind energy: Canadian Solar CSIQ, +0.74% , China High Speed Transmission 658, +0.65% , GCL-Poly 3800, -3.39% , Daqo New Energy DQ, +2.06% , and Jinko Solar JKS, +0.76% .

Not among the top companies? Electric-car makers, including Tesla Inc. TSLA, -5.59% . Elon Musk’s company has been an investor favorite for years, even eclipsing Ford Motor Co. F, -1.31% and General Motors GM, -1.86% in market cap.

Tesla shares are up nearly 66% so far this year, but the good it may have been doing for portfolios may not translate to it doing good for the planet. Morgan Stanley said this was one of the “biggest surprises” of its study.

The bank grouped the “climate-change impact stocks” into four sector categories: utilities, renewable manufacturers, green infrastructure companies and transportation stocks. It then analyzed them on a number of metrics, including “the CO2 [carbon dioxide] savings achieved from the products and services sold by the companies,” as well as secondary and tertiary factors centered around the environmental impact of the making of these products.

This is where Tesla, along with China’s Guoxuan High-Tech 002074, -0.52% , fall short.

“Whilst the electric vehicles and lithium batteries manufactured by these two companies do indeed help to reduce direct CO2 emissions from vehicles, electricity is needed to power them,” Morgan Stanley wrote. “And with their primary markets still largely weighted towards fossil-fuel power (72% in the U.S. and 75% in China) the CO2 emissions from this electricity generation are still material.”

In other words, “the carbon emissions generated by the electricity required for electric vehicles are greater than those saved by cutting out direct vehicle emissions.”

Morgan Stanley calculated that an investment of $1 million in Canadian Solar results in nearly 15,300 metric tons of carbon dioxide being saved every year. For Tesla, such an investment adds nearly one-third of a metric ton of CO2.

Morgan Stanley, which in February advocated for looking at gender diversity when analyzing companies, admitted that considering companies on a climate-change basis was not a perfect science.

“Very few if any stocks will have a 100% net positive impact,” read the report. “However, the extra layer of analysis on subsidiary effects must be a subjective judgement call, based on whether the additional impacts (of which there may be many) are sufficiently negative to offset the positive effect created by the core business.”

It added, “We even struggled to find total CO2 emissions data for most companies.”

Investing with an eye toward the environment is part of a growing trend of ESG investing, which stands for evaluating companies on environmental, social and governance grounds. Such investments favor companies that have strong environmental policies, or that treat their employees well, for example.

How to invest and do good

There are even funds that focus specifically on climate-change issues, like the iShares MSCI ACWI Low Carbon Target ETF CRBN, +0.64% or the SPDR MSCI ACWI Low Carbon Target ETF LOWC, +0.55% . Both exchange-traded funds have outperformed the broader S&P 500 so far this year, whereas the largest ETF to track the energy sector XLE, -1.03% recently dropped into bear-market territory, defined as a 20% drop from a peak.

The low-carbon funds have seen increased usage over the past year, something analysts credit to the election of President Donald Trump, whose administration is seen as hostile to environmentally friendly policies.

Read:Trump’s environmental policies are ‘galvanizing’ use of green ETFs