Password form redirection to belonging post

Here is all you need to make this work, plus your actual form of course:

function dopasswordstuff(){
   if(isset($_POST['homepagepassword'])){
    global $wpdb;
    $post_password = trim($_POST['passwordfield']);
    $post_id = $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_password = %s", $post_password) );
    if (!empty($post_id)) {
      wp_redirect(get_permalink($post_id));
    }
    exit;
   }
}
add_action('template_redirect','dopasswordstuff');

I simplified your function considerably by leveraging the fact that get_permalink will accept a post ID a parameter.

I hooked to template_redirect instead of init which seemed more appropriate.