dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: Huang Rui <ray.huang@amd.com>, Takashi Iwai <tiwai@suse.de>
Cc: "dri-devel@lists.freedesktop.org" <dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH] drm/ttm: Use scnprintf() for avoiding potential buffer overflow
Date: Wed, 11 Mar 2020 08:56:11 +0100	[thread overview]
Message-ID: <85766da1-7021-2ea1-990f-813f08d80cd8@amd.com> (raw)
In-Reply-To: <20200311075236.GB2835@jenkins-Celadon-RN>

Am 11.03.20 um 08:52 schrieb Huang Rui:
> On Wed, Mar 11, 2020 at 03:34:52PM +0800, Takashi Iwai wrote:
>> Since snprintf() returns the would-be-output size instead of the
>> actual output size, the succeeding calls may go beyond the given
>> buffer limit.  Fix it by replacing with scnprintf().
>>
>> Signed-off-by: Takashi Iwai <tiwai@suse.de>
> Reviewed-by: Huang Rui <ray.huang@amd.com>

Reviewed-by: Christian König <christian.koenig@amd.com>

Takashi, should I push this to drm-misc-next or do you want to merge 
that somehow else?

Thanks,
Christian.

>
>> ---
>>   drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
>> index bf876faea592..faefaaef7909 100644
>> --- a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
>> +++ b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
>> @@ -604,7 +604,7 @@ static struct dma_pool *ttm_dma_pool_init(struct device *dev, gfp_t flags,
>>   	p = pool->name;
>>   	for (i = 0; i < ARRAY_SIZE(t); i++) {
>>   		if (type & t[i]) {
>> -			p += snprintf(p, sizeof(pool->name) - (p - pool->name),
>> +			p += scnprintf(p, sizeof(pool->name) - (p - pool->name),
>>   				      "%s", n[i]);
>>   		}
>>   	}
>> -- 
>> 2.16.4
>>

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2020-03-11  7:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-11  7:34 [PATCH] drm/ttm: Use scnprintf() for avoiding potential buffer overflow Takashi Iwai
2020-03-11  7:52 ` Huang Rui
2020-03-11  7:56   ` Christian König [this message]
2020-03-11  7:57     ` Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=85766da1-7021-2ea1-990f-813f08d80cd8@amd.com \
    --to=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=ray.huang@amd.com \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox