Skip to content

Commit

Permalink
Fix null deref on server conn create failure
Browse files Browse the repository at this point in the history
  • Loading branch information
garlick committed Jun 14, 2011
1 parent a489bc2 commit 6c6521b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion libdiod/diod_sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ diod_sock_startfd (Npsrv *srv, int fd, char *client_id)
conn = np_conn_create (srv, trans, client_id);
if (!conn) {
errn (np_rerror (), "error creating connection for %s", client_id);
np_trans_destroy (trans);
/* trans is destroyed in np_conn_create on failure */
return;
}
}
Expand Down
6 changes: 3 additions & 3 deletions libnpfs/conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ np_conn_create(Npsrv *srv, Nptrans *trans, char *client_id)
int err;

if (!(conn = malloc(sizeof(*conn)))) {
errno = ENOMEM;
np_uerror(ENOMEM);
return NULL;
}
pthread_mutex_init(&conn->lock, NULL);
Expand All @@ -63,7 +63,7 @@ np_conn_create(Npsrv *srv, Nptrans *trans, char *client_id)
conn->shutdown = 0;
if (!(conn->fidpool = np_fidpool_create())) {
free (conn);
errno = ENOMEM;
np_uerror(ENOMEM);
return NULL;
}
snprintf(conn->client_id, sizeof(conn->client_id), "%s", client_id);
Expand All @@ -76,7 +76,7 @@ np_conn_create(Npsrv *srv, Nptrans *trans, char *client_id)
err = pthread_create(&conn->rthread, NULL, np_conn_read_proc, conn);
if (err != 0) {
np_conn_destroy (conn);
errno = err;
np_uerror (err);
return NULL;
}

Expand Down

0 comments on commit 6c6521b

Please sign in to comment.