[PATCH net v1] netmem: fix skb_frag_address_safe with unreadable skbs

From: Mina Almasry
Date: Tue Jun 17 2025 - 17:10:04 EST


skb_frag_address_safe() needs a check that the
skb_frag_page exists check similar to skb_frag_address().

Cc: ap420073@xxxxxxxxx

Signed-off-by: Mina Almasry <almasrymina@xxxxxxxxxx>
---
include/linux/skbuff.h | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 5520524c93bf..9d551845e517 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -3665,7 +3665,12 @@ static inline void *skb_frag_address(const skb_frag_t *frag)
*/
static inline void *skb_frag_address_safe(const skb_frag_t *frag)
{
- void *ptr = page_address(skb_frag_page(frag));
+ void *ptr;
+
+ if (!skb_frag_page(frag))
+ return NULL;
+
+ ptr = page_address(skb_frag_page(frag));
if (unlikely(!ptr))
return NULL;


base-commit: 7b4ac12cc929e281cf7edc22203e0533790ebc2b
--
2.50.0.rc2.696.g1fc2a0284f-goog