A number of users attempting to update to iOS 4.0.2 have reported problems updating, including “Error 9″ and another issue in which the update stalls partway through.
Fixes
Restore instead of update. Backup your iPhone, then perform a restore process instead of using the check for update function. This may allow the iPhone to successfully receive the iOS 4.0.2 update, after which sync processes should occur at normal speed.
Switch USB ports. Try switching your iPhone to a different USB port. In particular, if you are using a hub or other intermediary device, try connecting the device directly to your computer.
Disable network connection. In some cases, simply disabling your network connection (turning off AirPort or unplugging your Ethernet cable) right after you click the update button will resolve the slow or stuck backup phase. It appears that iTunes performs some data network data transfer during the backup process which can, for unknown reasons, take an extremely long time or become stalled.
Delete backup folder. If you are using a Mac, navigate to (your username)/Library/Application Support/MobileSync/Backup/ and delete the most recent backup folder.
If you are using Windows, delete the most recent backup folder from C:\Documents and Settings\Application Data\Apple Computer\MobileSync\Backup\.
Disable antivirus software. If you are using Windows, try temporarily disabling antivirus software before applying the update.