]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
USB: core: Use krealloc() in usb_cache_string()
authorBence Csókás <bence98@sch.bme.hu>
Sun, 15 Mar 2026 11:24:44 +0000 (12:24 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Mar 2026 15:03:52 +0000 (16:03 +0100)
commit1f50332c60c2f63118b6c8b41a61d0e43d707743
tree58f6480f40122208fe0e6458666959dadefb3850
parent0b9570c4ba5cbd2c0f9a282f649e4bcfce0d52af
USB: core: Use krealloc() in usb_cache_string()

Instead of "shrinking" the allocation by kmalloc()ing a new, smaller
buffer, utilize krealloc() to shrink the existing allocation. This saves
a memcpy(), as well as eliminates the temporary `smallbuf` allocation,
which guards against allocation failure under extreme memory pressure.

Signed-off-by: Bence Csókás <bence98@sch.bme.hu>
Link: https://patch.msgid.link/20260315-usb-krealloc-v2-1-32f83e090409@sch.bme.hu
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/core/message.c