Re: [PATCH 1/3] mm: Add kvrealloc()
From: Dave Chinner <david@fromorbit.com>
Date: 2021-06-25 05:05:17
Also in:
linux-xfs
From: Dave Chinner <david@fromorbit.com>
Date: 2021-06-25 05:05:17
Also in:
linux-xfs
On Fri, Jun 25, 2021 at 10:40:08AM +0800, Miaohe Lin wrote:
On 2021/6/25 10:30, Dave Chinner wrote:quoted
@@ -830,6 +830,20 @@ static inline void *kvcalloc(size_t n, size_t size, gfp_t flags) extern void kvfree(const void *addr); extern void kvfree_sensitive(const void *addr, size_t len); +static inline void *kvrealloc(void *p, size_t oldsize, size_t newsize, + gfp_t flags) +{ + void *newp; + + if (oldsize >= newsize) + return p; + newp = kvmalloc(newsize, flags);Shouldn't we check newp against NULL before memcpy?
Sure, the flags cwwe pass it from XFS mean it can't fail, but I guess someone could add a noretry flag or something like that... Cheers, Dave. -- Dave Chinner david@fromorbit.com