From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bo YU Subject: Re: [PATCH v2] drm: etnaviv: fix strncpy sizeof argument Date: Tue, 2 Apr 2019 09:30:38 +0800 Message-ID: References: <20190328080918.9290-1-tsu.yubo@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Return-path: In-Reply-To: <20190328080918.9290-1-tsu.yubo@gmail.com> Sender: linux-kernel-owner@vger.kernel.org To: l.stach@pengutronix.de, linux+etnaviv@armlinux.org.uk, Christian Gmeiner , airlied@linux.ie, Daniel Vetter , open list Cc: etnaviv@lists.freedesktop.org, dri-devel@lists.freedesktop.org, =?UTF-8?B?5LqO5rOi?= List-Id: dri-devel@lists.freedesktop.org On Thu, Mar 28, 2019 at 4:09 PM Bo YU wrote: > > 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 > --- > 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 > Ping?