kcsan: debugfs: Use krealloc_array() to replace krealloc()
PATCH 1/1 kcsan: debugfs: Use krealloc_array() to replace krealloc()
Use krealloc_array() to replace krealloc() with multiplication. krealloc_array() has multiply overflow check, which will be safer.
--- kernel/kcsan/debugfs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/kcsan/debugfs.c +3 -3
@@ -166,10 +166,10 @@ static ssize_t insert_report_filterlist(const char *func) }else if (report_filterlist.used == report_filterlist.size) {/* resize filterlist */ size_t new_size = report_filterlist.size *2 ; -unsigned long *new_addrs = -krealloc (report_filterlist.addrs, - new_size *sizeof (unsigned long ),GFP_ATOMIC ); +unsigned long *new_addrs; + new_addrs =krealloc_array (report_filterlist.addrs, + new_size,sizeof (*new_addrs),GFP_ATOMIC );if (new_addrs ==NULL ) {/* leave filterlist itself untouched */ ret = -ENOMEM ;
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
Quoted 5 lines · Andy Shevchenko
Use
krealloc_array()to replacekrealloc()with multiplication.krealloc_array()has multiply overflow check, which will be safer.Signed-off-by Andy Shevchenko <[email protected]>
Do you have a tree to take this through? Otherwise I'll take it.
Quoted 25 lines
--- kernel/kcsan/debugfs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)kernel/kcsan/debugfs.c +3
-4@@ -166,10 +166,10 @@ static ssize_t insert_report_filterlist(const char *func) }else if (report_filterlist.used == report_filterlist.size) {/* resize filterlist */ size_t new_size = report_filterlist.size *2 ; -unsigned long *new_addrs = -krealloc (report_filterlist.addrs, - new_size *sizeof (unsigned long ),GFP_ATOMIC ); +unsigned long *new_addrs; + new_addrs =krealloc_array (report_filterlist.addrs, + new_size,sizeof (*new_addrs),GFP_ATOMIC );if (new_addrs ==NULL ) {/* leave filterlist itself untouched */ ret = -ENOMEM ; --2.43.0.rc1.1336.g36b5255a03ac
Quoted 9 lines · Marco Elver
Quoted 5 lines · Andy Shevchenko
Use
krealloc_array()to replacekrealloc()with multiplication.krealloc_array()has multiply overflow check, which will be safer.Signed-off-by Andy Shevchenko <[email protected]>Reviewed-by Marco Elver <[email protected]>
Thank you!
Quoted 1 line
Do you have a tree to take this through? Otherwise I'll take it.
No, but please, wait a bit, I have a sequential dependent patch. I'll send a v2 soon.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Marco Elver
maintainerQuoted 10 lines · Marco Elver
Quoted 5 lines · Andy Shevchenko
Use
krealloc_array()to replacekrealloc()with multiplication.krealloc_array()has multiply overflow check, which will be safer.Signed-off-by Andy Shevchenko <[email protected]>Reviewed-by Marco Elver <[email protected]>
Unreview.
Quoted 1 line
Do you have a tree to take this through? Otherwise I'll take it.
Whoops. We got rid of that krealloc() in 59458fa4ddb4 ("kcsan: Turn report_filterlist_lock into a raw_spinlock"). And the replacement kmalloc() is already a kmalloc_array(). I suppose this patch is therefore obsolete.
Quoted 11 lines · Marco Elver
Quoted 9 lines · Marco Elver
Quoted 5 lines · Andy Shevchenko
Use
krealloc_array()to replacekrealloc()with multiplication.krealloc_array()has multiply overflow check, which will be safer.Signed-off-by Andy Shevchenko <[email protected]>Reviewed-by Marco Elver <[email protected]>
Quoted 8 lines
Unreview.
Quoted 1 line
Do you have a tree to take this through? Otherwise I'll take it.
Whoops. We got rid of that
krealloc()in59458fa4ddb4("kcsan: Turnreport_filterlist_lockinto araw_spinlock"). And the replacementkmalloc()is already akmalloc_array(). I suppose this patch is therefore obsolete.
Ah, I made this on top of v6.12 + something most likely unrelated.
Signature · 2 lines
With Best Regards, Andy Shevchenko