Apple has released iOS 4.0.2 firmware for iPhone 4, 3GS, 3G, and iPod Touch. You can download iOS 4.0.2 8A400 build from below. iPhone iOS 4.0.2 firmware Patches PDF exploit used in JailbreakMe jailbreak.
Jailbreakers and unlockers MUST stay away from iOS 4.0.2 update as it patches the exploit used in iOS 4.0.1 firmware. There’s no iPhone baseband update in this release but your iPhone needs to be jailbroken in order to unlock. So, Avoid iOS 4.0.2.