Valgrind gives an error for lines 17 and 21. What should I do to fix it?
int fd[2];
if (pipe(fd) == -1) {
    perror("pipe");
}

int r = fork();

if (r > 0) {  // Parent
    close(fd[0]);
    // // Connect stdout to pipe
    // dup2(fd[1], fileno(stdout));
    // close(fd[1]);

    // Feed information into the pipe
    if (write(fd[1], user_id, MAXLINE) == -1) {
        perror("write to pipe");
    }
    if (write(fd[1], password, MAXLINE) == -1) {
        perror("write to pipe");
    }

    close(fd[1]);

    int status;
    if (wait(&status) != -1) {
        if (WIFEXITED(status)) {
            printf("[%d] Child exited with %d\n", getpid(), WEXITSTATUS(status));
        } else {
            printf("[%d] Child exited abnormally\n", getpid());
        }
    }
} else if (r == 0) {  // Child
    // Connect stdin to pipe
    dup2(fd[0], fileno(stdin));
    close(fd[0]);
    close(fd[1]);

    // Call exec for validate
    execl("./validate", "validate", NULL);
}