The expand_name() function isn't called with the process lock held anymore,
so we can safely use malloc(M_WAITOK) now. Pointed out by: kib
This commit is contained in:
parent
44525d12bc
commit
086053a370
@ -3057,9 +3057,7 @@ expand_name(const char *comm, uid_t uid, pid_t pid, struct thread *td,
|
|||||||
|
|
||||||
hostname = NULL;
|
hostname = NULL;
|
||||||
format = corefilename;
|
format = corefilename;
|
||||||
name = malloc(MAXPATHLEN, M_TEMP, M_NOWAIT | M_ZERO);
|
name = malloc(MAXPATHLEN, M_TEMP, M_WAITOK | M_ZERO);
|
||||||
if (name == NULL)
|
|
||||||
return (NULL);
|
|
||||||
indexpos = -1;
|
indexpos = -1;
|
||||||
(void)sbuf_new(&sb, name, MAXPATHLEN, SBUF_FIXEDLEN);
|
(void)sbuf_new(&sb, name, MAXPATHLEN, SBUF_FIXEDLEN);
|
||||||
for (i = 0; format[i]; i++) {
|
for (i = 0; format[i]; i++) {
|
||||||
@ -3073,16 +3071,7 @@ expand_name(const char *comm, uid_t uid, pid_t pid, struct thread *td,
|
|||||||
case 'H': /* hostname */
|
case 'H': /* hostname */
|
||||||
if (hostname == NULL) {
|
if (hostname == NULL) {
|
||||||
hostname = malloc(MAXHOSTNAMELEN,
|
hostname = malloc(MAXHOSTNAMELEN,
|
||||||
M_TEMP, M_NOWAIT);
|
M_TEMP, M_WAITOK);
|
||||||
if (hostname == NULL) {
|
|
||||||
log(LOG_ERR,
|
|
||||||
"pid %ld (%s), uid (%lu): "
|
|
||||||
"unable to alloc memory "
|
|
||||||
"for corefile hostname\n",
|
|
||||||
(long)pid, comm,
|
|
||||||
(u_long)uid);
|
|
||||||
goto nomem;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
getcredhostname(td->td_ucred, hostname,
|
getcredhostname(td->td_ucred, hostname,
|
||||||
MAXHOSTNAMELEN);
|
MAXHOSTNAMELEN);
|
||||||
@ -3119,7 +3108,6 @@ expand_name(const char *comm, uid_t uid, pid_t pid, struct thread *td,
|
|||||||
if (sbuf_error(&sb) != 0) {
|
if (sbuf_error(&sb) != 0) {
|
||||||
log(LOG_ERR, "pid %ld (%s), uid (%lu): corename is too "
|
log(LOG_ERR, "pid %ld (%s), uid (%lu): corename is too "
|
||||||
"long\n", (long)pid, comm, (u_long)uid);
|
"long\n", (long)pid, comm, (u_long)uid);
|
||||||
nomem:
|
|
||||||
sbuf_delete(&sb);
|
sbuf_delete(&sb);
|
||||||
free(name, M_TEMP);
|
free(name, M_TEMP);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user