What's wrong with my cat EOF?

cat << EOF > tmp.sh
#!/bin/sh
mknod /dev/`cat /proc/devices | grep xx | sed -r 's/(.*) (.*)/\2 c \1/'` 0
chmod 777 /dev/xx

EOF is missing at the end, and because of grave accents you were facing problem

$ cat << 'EOF' > tmp.sh
> #!/bin/sh
> mknod /dev/`cat /proc/devices | grep xx | sed -r 's/(.*) (.*)/\2 c \1/'` 0
> chmod 777 /dev/xx
> EOF

$ cat tmp.sh 
#!/bin/sh
mknod /dev/`cat /proc/devices | grep xx | sed -r 's/(.*) (.*)/\2 c \1/'` 0
chmod 777 /dev/xx