dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] drm: etnaviv: fix strncpy sizeof argument
@ 2019-03-28  8:09 Bo YU
  2019-04-02  1:30 ` Bo YU
  0 siblings, 1 reply; 2+ messages in thread
From: Bo YU @ 2019-03-28  8:09 UTC (permalink / raw)
  To: l.stach, linux+etnaviv, christian.gmeiner, airlied, daniel,
	linux-kernel
  Cc: Bo YU, etnaviv, dri-devel, yuzibode

Calling strncpy with a maximum size argument of 64 bytes on destination
array "domain->name" of size 64 bytes might leave the destination string
unterminated.

Detected by CoverityScan, CID# 1443992:  Memory - illegal accesses (BUFFER_SIZE_WARNING)

Fixes: 9e2c2e2730126 (drm/etnaviv: add infrastructure to query perf counter)
Signed-off-by: Bo YU <tsu.yubo@gmail.com>
---
v2: accroding to Russell's suggestion, replace strncpy with strlcpy
---
 drivers/gpu/drm/etnaviv/etnaviv_perfmon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/etnaviv/etnaviv_perfmon.c b/drivers/gpu/drm/etnaviv/etnaviv_perfmon.c
index 4227a4006c34..ce178f23e86a 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_perfmon.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_perfmon.c
@@ -414,7 +414,7 @@ int etnaviv_pm_query_dom(struct etnaviv_gpu *gpu,
 
 	domain->id = domain->iter;
 	domain->nr_signals = dom->nr_signals;
-	strncpy(domain->name, dom->name, sizeof(domain->name));
+	strlcpy(domain->name, dom->name, sizeof(domain->name));
 
 	domain->iter++;
 	if (domain->iter == meta->nr_domains)
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-04-02  1:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-28  8:09 [PATCH v2] drm: etnaviv: fix strncpy sizeof argument Bo YU
2019-04-02  1:30 ` Bo YU

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox