Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp5768547pxu; Thu, 22 Oct 2020 10:31:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxXq+yU7CJvGqFmM/CAuyWj3nt844kPoaqKFp4ZzWTE/2C3WnX8LQhFb38FcqBndUoXeFY6 X-Received: by 2002:aa7:d7d9:: with SMTP id e25mr3227156eds.253.1603387866767; Thu, 22 Oct 2020 10:31:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603387866; cv=none; d=google.com; s=arc-20160816; b=IM2frnq3LnjF1WdYtNwgBLQ2rOA1Pxt1cmeTqkVcVoS79yjyeLfelM/d/c5WQsFj97 L8uhzvEvCnnlaDSsTjDmQdyIsTGAw98hvhxv75bdvE9bvGWof0f5P67treyIBmcs3JyU Eth3+95zjTF73ntTWDuaCJYlHzfd4MMyyxvE9Aj2UIRVLhMvYEWt+yZdr8uEJq61d1X4 bhYMu1SyUFyn9n5CpXWSzAkW2I863KNk6y9Popa3uR85cvnMGpbXelrGb+hCY0HBiquS aQHL3+OXMZMpw6eIKvwZqVRYisQtZ26sH437fO6O6ZsB4YlDfnpBbDKSblLbYhV/JO/V VMqQ== 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=U432S97cU+kXrslvGgog8CihEs2p/DakYW0kgHJLU04=; b=0GdeRJxM0Bjx7neO89RxFdUZ6l83kQar2L2+tBOkTWeht2TWp7TC4MJ575xnpbQOwQ NKweixibpJmOy88d2RFCYTKbYMQLXuytBiHAMDIOK/GDIcr6DIM9yTP3rKTkQA2vkP4K 8gk8vNI22bT8K8QIGQggWX2SPbwFwyvLzN14IesKV3tGcusjoOMNJqiudRh0bLNwfjuP TflXuBM18/rCwMs4zobtSnvHA64mkp8TgOxIJ6MWUpaG6mqN8RZ63xKJ1lheAgTTzzt5 ogM9hZwmLZooHZJw8NNtob+hy0zasfuk+IV9RKdNlKr7nEgM5ZYyCggDf0znvEnxE7K/ vzwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rYwjb2xk; 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 lh5si1325416ejb.506.2020.10.22.10.30.44; Thu, 22 Oct 2020 10:31:06 -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=rYwjb2xk; 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 S2900454AbgJVNsD (ORCPT + 99 others); Thu, 22 Oct 2020 09:48:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2900448AbgJVNsC (ORCPT ); Thu, 22 Oct 2020 09:48:02 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75501C0613CE; Thu, 22 Oct 2020 06:48:02 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id l2so1000157pjt.5; Thu, 22 Oct 2020 06:48:02 -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=U432S97cU+kXrslvGgog8CihEs2p/DakYW0kgHJLU04=; b=rYwjb2xkkh0hxJWaPtOnGa4hSe5DuH6RLUZsZBwxA6M+Z3ZP+laaYWty/n+xFUh7CT x62XiY4/BFnQkTugiegwK2EiFTnJxllQ/XJKCth8g5mxJ93KuTm6ClHqTZ8sBEI+L1hq C/X1pxD7EjWrJ4/3qk4xaMAAEFtZKDHCo7Sjpb7ezoHZNY5/k26tuFpTDDtl4JTmW4v0 3+QVKvhFHvha8uUUEE7iCJl2d90+KRDbgRLvBeKbJ2RylZwbMd1l+gVJSnmaRTiDjFb1 N/sk7fU/JL99mAX5kVZbQ+JYnhO6HLzCtiGv1N1tQoIOymoGU077WXHGYycWfasE6u12 yQnw== 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=U432S97cU+kXrslvGgog8CihEs2p/DakYW0kgHJLU04=; b=scdaVRKj04/9RKKn9LHS9nZqbgokIAbbV5MG3HV/FySLRyEP+KtMgiS2XJHZ+Gh4S9 b4/L2RcBUtkinrpI36SQM5mGnaq7bv9BWtRCxDuVhG3UNIasJYZnMx0Qca2pHuj3iyNv hWdi5oIYe5IFjwZvMRkFjmB+KoIyFuXMyXpd4AhzFqqNygvxHf5lqzJWATYmqAj77Xzs 0/fuSHmZHCAJkKGX1XHrjNOj+ryCrJdEuUHa73lTcVct/622l54Lw/N2nw7E5ITEInNo 0tVyQL6JGJOvc2EnwP1wTG+TyS/cEa+RHEMdFpEYrlc4V4B7FjqzHXRU8TNqVkN3iEyT O8Yg== X-Gm-Message-State: AOAM530vhCT4Eb70JuBVPUhvpk7ZW5H954U0bOz1awTtTt1p/ytbZPgA NjC/xrwNE1NplAFDUtAlj+Vfi1bGnCM2Rw== X-Received: by 2002:a17:902:e983:b029:d5:f469:60c0 with SMTP id f3-20020a170902e983b02900d5f46960c0mr2536227plb.61.1603374481995; Thu, 22 Oct 2020 06:48:01 -0700 (PDT) Received: from adolin ([49.207.204.75]) by smtp.gmail.com with ESMTPSA id g17sm2357979pfu.130.2020.10.22.06.47.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Oct 2020 06:48:01 -0700 (PDT) Date: Thu, 22 Oct 2020 19:17:56 +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 4/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_psp.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_psp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c index d6c38e24f130..4d1d1e1b005d 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c @@ -2621,7 +2621,7 @@ static ssize_t psp_usbc_pd_fw_sysfs_read(struct device *dev, return ret; } - return snprintf(buf, PAGE_SIZE, "%x\n", fw_ver); + return sysfs_emit(buf, PAGE_SIZE, "%x\n", fw_ver); } static ssize_t psp_usbc_pd_fw_sysfs_write(struct device *dev, -- 2.25.1