Stocks rose on Tuesday as expectations grew that a default of Greek debt could be avoided and sovereign risk in other euro zone countries could be contained.

Euro zone finance ministers said the Greek government had until July 3 to approve new steps to get the next installment of 110 billion euros in European Union and International Monetary Fund aid.

A consensus grew that Greek Prime Minister George Papandreou would survive a confidence vote on Tuesday -- a key hurdle the government must clear to avert the euro zone's first sovereign debt default. The vote is due around 5 p.m. EDT.

The Greek debt has been an issue in the market for a year and a half. Now it's in the front and center. This (vote) is not the end of it, but it will deflect market concerns for a while, said Tim Ghriskey, chief investment officer of Solaris Asset Management in Bedford Hills, New York.

The Dow Jones industrial average <.DJI> was up 40.00 points, or 0.33 percent, at 12,120.38. The Standard & Poor's 500 Index <.SPX> was up 5.15 points, or 0.40 percent, at 1,283.51. The Nasdaq Composite Index <.IXIC> was up 6.91 points, or 0.26 percent, at 2,636.57.

In company news, Walgreen Co shares fell 5.2 percent to $42.84 after the drugstore chain reported higher quarterly earnings, but said efforts to renew an agreement with pharmacy benefits manager Express Scripts Inc failed.

Barnes & Noble Inc , the largest U.S. bookstore chain, reported a deeper quarterly loss as sales came under pressure from going-out-of-business sales at rival Borders Group Inc. The stock was down 2 percent at $19.75.

U.S.-traded shares of Research In Motion Ltd rebounded to rise 2.7 percent to $26.55 after falling about 7 percent on Monday. The company lost a second marketing executive in the latest bit bad news that has cut the BlackBerry maker's market value in half this year.

U.S. home sales data for May was due at 10 a.m. EDT. Analysts in a Reuters survey expected sales to drop to about 4.8 million, compared with 5.05 million the month before.

(Reporting by Angela Moon; editing by Jeffrey Benkoe)