Smooth extension of a smooth map on an non-empty open subset of a manifold to the whole manifold. Proposition: Suppose $M$ is a smooth manifold and $\emptyset\neq U\subset M$ is open and $f:U\rightarrow \mathbb{R}$ is a smooth function. Then $f$ does not necessarily extend smoothly to M.
Proof: (Counterexample). Let $M=\mathbb{S}^1$ and $U=\mathbb{S}^1\setminus\{p\}$ where $p$ is the 'north pole' (i.e. if we think of $\mathbb{S}^1$ as embedded in $\mathbb{R}^2$ then $p=(1,0)$). Define the map $f:U\rightarrow \mathbb{R}$ by stereographic projection, 
$f:(x_0,x_1)\in \mathbb{S}^1\setminus \{p\}\mapsto \frac{x_1}{1-x_0}\in \mathbb{R}$ which is well-defined and smooth since $x_0\neq 0$ on $U$. If we attempt to extend this map to $\mathbb{S}^1$ then $p$ must map to $\infty$ by continuity. However $\infty\not\in \mathbb{R}$, hence $\nexists$ a smooth extension of $f$ to all of $\mathbb{S}^1$. 
Is this a valid counterexample or have I missed something obvious? If my proposition is wrong could you please provide a reference for the proof? Thanks!
 A: Here is a "universal counterexample".
Let $\emptyset\neq U\subset M$ be open and not closed. Then there exists a smooth function $f : U \to \mathbb{R}$ which does not have a continuous extension to $M$.
Since $U$ is not closed, there exists $x \in M \setminus U$ and a sequence $(x_n)$ in $U$ which converges to $x$. The set $X = \{ x_n \mid n \in \mathbb{N} \}$ is closed in $U$. Choose a chart $h : V \to V' \subset \mathbb{R}^n$ around $x$. W.l.o.g. we may assume that all $x_n \in V$ and $x_n \ne x_m$ for $n \ne m$. Considering the sequence $(h(x_n))$ in $h(U \cap V) \subset \mathbb{R}^n$ which converges to $h(x)$, we can easily construct pairwise disjoint open neigbhorhoods $U_n \subset U \cap V$ of $x_n$. The $U_n$ and $U_\infty = U \setminus X$ form an open cover of $U$. Let $\varphi_n : U \to \mathbb{R}$ be a subordinated smooth partition of unity, $n \in \mathbb{N} \cup \{\infty \}$. Then $f(x) = \sum_{n=1}^\infty n \varphi_n(x)$ defines a smooth function $f : U \to \mathbb{R}$ such that $f(x_n) \to \infty$ as $n \to \infty$. It is obviuos that $f$ cannot have a continuous extension to $M$.
