mirror of https://github.com/torvalds/linux.git
signalfd: convert do_signalfd4() to FD_ADD()
Link: https://patch.msgid.link/20251123-work-fd-prepare-v4-14-b6efa1706cfd@kernel.org Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
parent
360fbf808a
commit
5b755da105
|
|
@ -250,8 +250,6 @@ static const struct file_operations signalfd_fops = {
|
||||||
|
|
||||||
static int do_signalfd4(int ufd, sigset_t *mask, int flags)
|
static int do_signalfd4(int ufd, sigset_t *mask, int flags)
|
||||||
{
|
{
|
||||||
struct signalfd_ctx *ctx;
|
|
||||||
|
|
||||||
/* Check the SFD_* constants for consistency. */
|
/* Check the SFD_* constants for consistency. */
|
||||||
BUILD_BUG_ON(SFD_CLOEXEC != O_CLOEXEC);
|
BUILD_BUG_ON(SFD_CLOEXEC != O_CLOEXEC);
|
||||||
BUILD_BUG_ON(SFD_NONBLOCK != O_NONBLOCK);
|
BUILD_BUG_ON(SFD_NONBLOCK != O_NONBLOCK);
|
||||||
|
|
@ -263,7 +261,8 @@ static int do_signalfd4(int ufd, sigset_t *mask, int flags)
|
||||||
signotset(mask);
|
signotset(mask);
|
||||||
|
|
||||||
if (ufd == -1) {
|
if (ufd == -1) {
|
||||||
struct file *file;
|
int fd;
|
||||||
|
struct signalfd_ctx *ctx __free(kfree) = NULL;
|
||||||
|
|
||||||
ctx = kmalloc(sizeof(*ctx), GFP_KERNEL);
|
ctx = kmalloc(sizeof(*ctx), GFP_KERNEL);
|
||||||
if (!ctx)
|
if (!ctx)
|
||||||
|
|
@ -271,22 +270,16 @@ static int do_signalfd4(int ufd, sigset_t *mask, int flags)
|
||||||
|
|
||||||
ctx->sigmask = *mask;
|
ctx->sigmask = *mask;
|
||||||
|
|
||||||
ufd = get_unused_fd_flags(flags & O_CLOEXEC);
|
fd = FD_ADD(flags & O_CLOEXEC,
|
||||||
if (ufd < 0) {
|
anon_inode_getfile_fmode(
|
||||||
kfree(ctx);
|
"[signalfd]", &signalfd_fops, ctx,
|
||||||
return ufd;
|
O_RDWR | (flags & O_NONBLOCK), FMODE_NOWAIT));
|
||||||
}
|
if (fd >= 0)
|
||||||
|
retain_and_null_ptr(ctx);
|
||||||
file = anon_inode_getfile_fmode("[signalfd]", &signalfd_fops,
|
return fd;
|
||||||
ctx, O_RDWR | (flags & O_NONBLOCK),
|
|
||||||
FMODE_NOWAIT);
|
|
||||||
if (IS_ERR(file)) {
|
|
||||||
put_unused_fd(ufd);
|
|
||||||
kfree(ctx);
|
|
||||||
return PTR_ERR(file);
|
|
||||||
}
|
|
||||||
fd_install(ufd, file);
|
|
||||||
} else {
|
} else {
|
||||||
|
struct signalfd_ctx *ctx;
|
||||||
|
|
||||||
CLASS(fd, f)(ufd);
|
CLASS(fd, f)(ufd);
|
||||||
if (fd_empty(f))
|
if (fd_empty(f))
|
||||||
return -EBADF;
|
return -EBADF;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue