]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: netdevsim: fix nsim_pp_hold_write()
authorEric Dumazet <edumazet@google.com>
Mon, 16 Dec 2024 08:37:03 +0000 (08:37 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 27 Dec 2024 13:02:04 +0000 (14:02 +0100)
[ Upstream commit b9b8301d369b4c876de5255dbf067b19ba88ac71 ]

nsim_pp_hold_write() has two problems:

1) It may return with rtnl held, as found by syzbot.

2) Its return value does not propagate an error if any.

Fixes: 1580cbcbfe77 ("net: netdevsim: add some fake page pool use")
Reported-by: syzbot <syzkaller@googlegroups.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20241216083703.1859921-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/netdevsim/netdev.c

index 017a6102be0a220175523c6130de840f3a5997fb..1b29d1d794a201180dace1d83cbf395356249212 100644 (file)
@@ -596,10 +596,10 @@ nsim_pp_hold_write(struct file *file, const char __user *data,
                page_pool_put_full_page(ns->page->pp, ns->page, false);
                ns->page = NULL;
        }
-       rtnl_unlock();
 
 exit:
-       return count;
+       rtnl_unlock();
+       return ret;
 }
 
 static const struct file_operations nsim_pp_hold_fops = {