A search for a Higgs boson decaying into two photons is described. The analysis is performed using a dataset recorded by the CMS experiment at the LHC from pp collisions at a centre-of-mass energy of 7~TeV, and corresponds to an integrated luminosity of 4.8~fb. Limits are set on the cross section of a standard model Higgs boson decaying to two photons. The expected exclusion limit at 95\% confidence level is between 1.2 and 2.1 times the standard model cross section in the mass range 110150\,GeV. The observed limit excludes at 95\% confidence level a standard model Higgs boson decaying into two photons in the mass ranges 110.0111.0, 117.5120.5, 128.5132.0, 139.0140.0 and 146.0147.0\,GeV. The largest excess of events over the expected background is observed around 125\,GeV. Taking into account the look-elsewhere effect in the search range 110150\,GeV the excess has a global significance of 1.6 standard deviations. More data are required to ascertain the origin of this excess.