mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 19:08:57 +09:00
Revert "CHROMIUM: usb: gadget: configfs: Fix KASAN use-after-free"
This reverts commitd7b2c97fd0. Relpaced by commitc3a4fc9f37("usb: gadget: configfs: Fix KASAN use-after-free"). Signed-off-by: Tao Huang <huangtao@rock-chips.com> Change-Id: I838bfe4ef5d3a7ba3ce4296f76434cfc3d33c991
This commit is contained in:
@@ -140,28 +140,21 @@ struct gadget_config_name {
|
||||
struct list_head list;
|
||||
};
|
||||
|
||||
#define MAX_USB_STRING_LEN 126
|
||||
#define MAX_USB_STRING_WITH_NULL_LEN (MAX_USB_STRING_LEN+1)
|
||||
|
||||
static int usb_string_copy(const char *s, char **s_copy)
|
||||
{
|
||||
int ret;
|
||||
char *str;
|
||||
char *copy = *s_copy;
|
||||
ret = strlen(s);
|
||||
if (ret > MAX_USB_STRING_LEN)
|
||||
if (ret > 126)
|
||||
return -EOVERFLOW;
|
||||
|
||||
if (copy) {
|
||||
str = copy;
|
||||
} else {
|
||||
str = kmalloc(MAX_USB_STRING_WITH_NULL_LEN, GFP_KERNEL);
|
||||
if (!str)
|
||||
return -ENOMEM;
|
||||
}
|
||||
strncpy(str, s, MAX_USB_STRING_WITH_NULL_LEN);
|
||||
str = kstrdup(s, GFP_KERNEL);
|
||||
if (!str)
|
||||
return -ENOMEM;
|
||||
if (str[ret - 1] == '\n')
|
||||
str[ret - 1] = '\0';
|
||||
kfree(copy);
|
||||
*s_copy = str;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user