Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp5766090pxu; Thu, 22 Oct 2020 10:27:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwM/2GkHdpgnGplhktkyjFahx3chm2hq6ACot7D+7wReW9mn56uJe4/jb8Zs6Fp4VaVgsO X-Received: by 2002:a17:906:5d9:: with SMTP id t25mr3245433ejt.443.1603387635493; Thu, 22 Oct 2020 10:27:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603387635; cv=none; d=google.com; s=arc-20160816; b=vcWeKNvOU9LQfmDxBTtbM6OxOLOfm782iuYJvB65YwsDvJSxzSKZOYxfHjX8NtbqEo vWQACDCtqufOp9tTME5csZDRU+XAIPcKzvXrwQWGqZU3zJxAlQgV/2xBwZj6zOud1fNO SyV7K8Mn7mQMD0jrl23/CN+h6qLNNTjpJmr/hT8na7JGta6VVRgNjxmCtYLhdB9Zvy5k JrxuZ/W6UldBfb5HGz7Q1S9QyapPRlx/JMNgXLOKcf5JKcTWcVwXN/pRtovJDeYyCMbe AdRNccp8k3ASXRPk0VY3FCgpZVJieIeLCyM95ADmh2Xvzp/yNAwsfNuo43jO+YIbieWO MNzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=6ARfb7CCtAyGQWozbpcu69TiW9MOgZYC7V52jr9EMdI=; b=06Aqs0QnWuSWqdCYg69xF3ihGBFIBbQhoWh30cWnMaSbMIa0zSS5bBobbhkhlYGEjA btsz3C/4wtD7EwyamAPxKFklI6KB18+k6Rp87umb8mXD1YNtBtz3MSGGS8mfbXICDeLq xfKruZnlzp3Bu8UDMnljUiYOBHgUB3KmMYlc5HW5xXtUaEVRInS3iEwi7Xvd9f0Jf1An TLQk1CRqs8LcMNMemfzJjB0SOQLWZBjU75z1TgZeehwKrfh4PK7e9DNciFNNbgjRlINx +1l/teUWh+CjdKM0GnTseDVThV20MaJVrSW8B2TsdVYIcwSfXYNX7jAmGN2HhBDuumGn TzAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cPArrMKj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o13si1454080ejb.631.2020.10.22.10.26.53; Thu, 22 Oct 2020 10:27:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cPArrMKj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2508058AbgJVNk4 (ORCPT + 99 others); Thu, 22 Oct 2020 09:40:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2503436AbgJVNk4 (ORCPT ); Thu, 22 Oct 2020 09:40:56 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D2A6C0613CE; Thu, 22 Oct 2020 06:40:53 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id j5so592780plk.7; Thu, 22 Oct 2020 06:40:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=6ARfb7CCtAyGQWozbpcu69TiW9MOgZYC7V52jr9EMdI=; b=cPArrMKj7xSwULJAYitN0m6vC7G/wTwv5trn8fq+nwf0A+2hp5LU49pAbuMhjjeNRv fccwBKY40gL96fMEFCrheOhs7geOIGvy7bVVSiZb4TMh4d4+F5geRTxSuZJZ70PQlJbl jsiGe1Txe6jSe3uD8rQo5YbSLjz9pGZZWV6R8BiMnBJXhF7UUdTOm46R+31AxuvTjs8f 4vG70Oj+1gjW8V8CgysBCTnZOVSLzF1KzDbUBCBO/FFxF/jhtqBUeM7IYE1nzUP+YPj1 KYWxc2DLWI7L4c9F3cvB8q3/pRjebyP3rk0NZq4DzfnO71JrJupHUchu1cnsxLwnxa3y INBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=6ARfb7CCtAyGQWozbpcu69TiW9MOgZYC7V52jr9EMdI=; b=uiw5gO+c1W1f1lG0ljp5OGHvdvP5n6Eyc8bBeN1LWaMpO4079VYQZPLooxZhEosnZF eV9RWPbZllz58UVTnyOGViHvuDSs/RIHT3C/1tJSZ5jaL+G7SlM59oOMFU3u2mzXxQpe RQkG0w/UZz7FVWSGUq1U5u6bYTWijbWl6/MfTdsyH+wtOQbSmP4yWNeXsuRwx/1IV2PD f1FdIpI4fgrO5JqF44PWu5FtSsn/vOwpXgQUjThQQCYdKNzvthtXpfQFpsCrlCbUfDQL vAgCPgRH4+ABYgohh+GuaKcH0Kb0dPJE3FkT9NwneA9hv8Z+IFZYQrlV58gzxiIIfNLC kGmg== X-Gm-Message-State: AOAM531gTSNPytr20GeezB+9HvUSTEO+w/17hHROV39bR9E9cWjrBDAN WwiOVJWEILruYtaaEf0Uj4g= X-Received: by 2002:a17:90a:7d12:: with SMTP id g18mr2448814pjl.89.1603374053035; Thu, 22 Oct 2020 06:40:53 -0700 (PDT) Received: from adolin ([49.207.204.75]) by smtp.gmail.com with ESMTPSA id j20sm2384100pgl.40.2020.10.22.06.40.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Oct 2020 06:40:52 -0700 (PDT) Date: Thu, 22 Oct 2020 19:10:47 +0530 From: Sumera Priyadarsini To: dri-devel@lists.freedesktop.org Cc: outreachy-kernel@googlegroups.com, alexander.deucher@amd.com, christian.koenig@amd.com, airlied@linux.ie, daniel@ffwll.ch, melissa.srw@gmail.com, linux-media@vger.kernel.org, amd-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/5] gpu: drm: amdgpu: Replace snprintf() with sysfs_emit() Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Using snprintf() for show() methods holds the risk of buffer overrun as snprintf() does not know the PAGE_SIZE maximum of the temporary buffer used to output sysfs content. Modify amdgpu_atombios.c to use sysfs_emit() instead which knows the size of the temporary buffer. Issue found with Coccinelle. Signed-off-by: Sumera Priyadarsini --- drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c index 469352e2d6ec..3c19862c94c7 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c @@ -1947,7 +1947,7 @@ static ssize_t amdgpu_atombios_get_vbios_version(struct device *dev, struct amdgpu_device *adev = drm_to_adev(ddev); struct atom_context *ctx = adev->mode_info.atom_context; - return snprintf(buf, PAGE_SIZE, "%s\n", ctx->vbios_version); + return sysfs_emit(buf, PAGE_SIZE, "%s\n", ctx->vbios_version); } static DEVICE_ATTR(vbios_version, 0444, amdgpu_atombios_get_vbios_version, -- 2.25.1