gcov: fix memory allocation problem in gcov_info_dup
PATCH 1/1 gcov: fix memory allocation problem in gcov_info_dup
From: Yuan Pengfei <[email protected]>
If -fprofile-values option is used, ctr->num and sci_ptr->num may be zero, resulting in zero size and cv_size, which will cause ENOMEM when opening gcov data files in debugfs.
--- kernel/gcov/gcc_3_4.c | 2 +- kernel/gcov/gcc_4_7.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
kernel/gcov/gcc_3_4.c +1 -1
@@ -269,7 +269,7 @@ struct gcov_info *gcov_info_dup(struct gcov_info *info) dup->counts[i].num = ctr->num; dup->counts[i].merge = ctr->merge; dup->counts[i].values =vmalloc (size); -if (!dup->counts[i].values) +if (size && !dup->counts[i].values) goto err_free;memcpy (dup->counts[i].values, ctr->values, size); }
kernel/gcov/gcc_4_7.c +1 -1
@@ -290,7 +290,7 @@ struct gcov_info *gcov_info_dup(struct gcov_info *info) dci_ptr->values =vmalloc (cv_size); -if (!dci_ptr->values) +if (cv_size && !dci_ptr->values) goto err_free; dci_ptr->num = sci_ptr->num;
Signature · 1 line
1.8.5.3���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m����������?�I�Quoted 6 lines · Yuan Pengfei
From: Yuan Pengfei <[email protected]>
If -fprofile-values option is used,
ctr->numandsci_ptr->nummay be zero, resulting in zero size andcv_size, which will cause ENOMEM when opening gcov data files in debugfs.Signed-off-by Yuan Pengfei <[email protected]>
I'm unaware of any user of -fprofile-values in the kernel. Are you trying to extend gcov-kernel to also support -fprofile-values? I would expect that additional changes to the .gcda file creation logic are required to fully support this GCC option.
Regards,
Peter Oberparleiter
Signature · 2 lines
Peter Oberparleiter Linux on System z Development - IBM Germany
Using -fprofile-values is one case that will cause the memory allocation problem. More changes are needed to fully support -fprofile-values. I submit this patch first because I think it is obvious and does no harm.
Quoted 4 lines
I'm unaware of any user of -fprofile-values in the kernel. Are you
trying to extend gcov-kernel to also support -fprofile-values? I would
expect that additional changes to the .gcda file creation logic are
required to fully support this GCC option.���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m����������?�I�
Quoted 7 lines · Yuan Pengfei
Using -fprofile-values is one case that will cause the memory allocation problem. More changes are needed to fully support -fprofile-values. I submit this patch first because I think it is obvious and does no harm.
Quoted 4 lines
I'm unaware of any user of -fprofile-values in the kernel. Are you trying to extend gcov-kernel to also support -fprofile-values? I would expect that additional changes to the .gcda file creation logic are required to fully support this GCC option.
If there is a way to trigger the problem of gcov_info.values == NULL using the existing gcov-kernel infrastructure then I agree that this should be fixed. If not, then I would rather see the suggested change as part of a patch series that enables other profiling types.
Signature · 2 lines
Peter Oberparleiter Linux on System z Development - IBM Germany