* [PATCH] fio: fix smalloc strdop allocation failure
@ 2015-03-03 11:44 Christian Ehrhardt
2015-03-03 22:09 ` Jens Axboe
0 siblings, 1 reply; 2+ messages in thread
From: Christian Ehrhardt @ 2015-03-03 11:44 UTC (permalink / raw)
To: fio; +Cc: Christian Ehrhardt, Christian Ehrhardt
From: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
smalloc_strdup didn't check for allocation success and thereby ran into
segfaults if the single pool went out of memory.
Now with this patch applied it is still failing, but in a more consistent
way than segfaulting.
You still get a bad allocation, but it looks like this now:
fio: smalloc OOM
fio: filesetup.c:1495: dup_files: Assertion `0' failed.
Aborted
In fact the upper layers expected smalloc_strdup to retrun NULL on failure.
Signed-off-by: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
---
[diffstat]
smalloc.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
[diff]
---
smalloc.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
--- a/smalloc.c
+++ b/smalloc.c
@@ -492,9 +492,10 @@ void *scalloc(size_t nmemb, size_t size)
char *smalloc_strdup(const char *str)
{
- char *ptr;
+ char *ptr = NULL;
ptr = smalloc(strlen(str) + 1);
- strcpy(ptr, str);
+ if (ptr)
+ strcpy(ptr, str);
return ptr;
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] fio: fix smalloc strdop allocation failure
2015-03-03 11:44 [PATCH] fio: fix smalloc strdop allocation failure Christian Ehrhardt
@ 2015-03-03 22:09 ` Jens Axboe
0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2015-03-03 22:09 UTC (permalink / raw)
To: Christian Ehrhardt, fio; +Cc: Christian Ehrhardt
On 03/03/2015 04:44 AM, Christian Ehrhardt wrote:
> From: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
>
> smalloc_strdup didn't check for allocation success and thereby ran into
> segfaults if the single pool went out of memory.
> Now with this patch applied it is still failing, but in a more consistent
> way than segfaulting.
>
> You still get a bad allocation, but it looks like this now:
> fio: smalloc OOM
> fio: filesetup.c:1495: dup_files: Assertion `0' failed.
> Aborted
>
> In fact the upper layers expected smalloc_strdup to retrun NULL on failure.
>
> Signed-off-by: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
Applied, thanks.
--
Jens Axboe
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-03-03 22:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-03 11:44 [PATCH] fio: fix smalloc strdop allocation failure Christian Ehrhardt
2015-03-03 22:09 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox