Commit 2985b18
PCI: Fix reset_method_store() memory leak
In reset_method_store(), a string is allocated via kstrndup() and assigned
to the local "options". options is then used in with strsep() to find
spaces:
while ((name = strsep(&options, " ")) != NULL) {
If there are no remaining spaces, then options is set to NULL by strsep(),
so the subsequent kfree(options) doesn't free the memory allocated via
kstrndup().
Fix by using a separate tmp_options to iterate with strsep() so options is
preserved.
Link: https://lore.kernel.org/r/20241001231147.3583649-1-tkjos@google.com
Fixes: d88f521 ("PCI: Allow userspace to query and set device reset mechanism")
Signed-off-by: Todd Kjos <tkjos@google.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>1 parent 43ee11a commit 2985b18
1 file changed
+3
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5244 | 5244 | | |
5245 | 5245 | | |
5246 | 5246 | | |
5247 | | - | |
| 5247 | + | |
5248 | 5248 | | |
5249 | 5249 | | |
5250 | 5250 | | |
| |||
5264 | 5264 | | |
5265 | 5265 | | |
5266 | 5266 | | |
5267 | | - | |
| 5267 | + | |
| 5268 | + | |
5268 | 5269 | | |
5269 | 5270 | | |
5270 | 5271 | | |
| |||
0 commit comments