Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp63752rdb; Thu, 1 Feb 2024 02:03:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IEQKOTBJ9igI+mhvjsvL1OPx3hGaQLZ2eSbW6/J3C4zPF9BJXnrqRRx6SzVC8Fynde756dm X-Received: by 2002:a05:651c:b0b:b0:2d0:7728:27d3 with SMTP id b11-20020a05651c0b0b00b002d0772827d3mr1071059ljr.42.1706781816993; Thu, 01 Feb 2024 02:03:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706781816; cv=pass; d=google.com; s=arc-20160816; b=YOSegX4DzMEaZjKzhB5iTBfPeogoG/ynuF+wBTLsaLkzaQTUcbcVhfyvoq9XmX3Dlv UoqvXYA5MnH1mt0qd9ojYFCYnu70opAiK0AoMLYmkpEBPJAYL2BIcd2dkk0KjpLOvOcj FtiLTK195uK+18ScXuDrnonifV2YrVUZC9RAwKU/rWUbq8RbeRKFq/wq2BD5Kl23CCfc TQTxAiRA5R8HpoGdXFnC3JN7b7+qxrNO0F3E/7N7l7VyXb6ZLqnpjTMMDJAYHOAF2PWE 0Hv5mBsS/QhgLu13jrasb9RJBxCS0NSdAUUcMUnNh23xmsbWcGJbTspMu2MS2hBxgzjr bCkQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:references:organization:in-reply-to:subject:cc:to :from:dkim-signature; bh=MS5TtNvSjClikbPo6N5o/JRVPL+t/4ahVj7xu5zL3R0=; fh=NxhSX1qh9zP0yDuDhQoL3aqxddTYBtKj9ctZsk6Ah9U=; b=Y4HAedTnEJEjFzkd/I+ymsrrM0V7op8baDAn9lWAweIn83p8lfI5qh+RLVW6eFtUQi LUVRMd03BXyw7fw7kYcRkXMndnZbp7p37m3lwKKUyxjiAGYxqj76RUr6SwRe0ZFJLgR5 NeczvszYrBLArX4CXphKv754PposQxPg855qwWoAQPPXXnpYZ0X+XKsGa83gAIuSp096 edQF2Gyo+Ft9glsguzYOoegHD0qpy9Wo8nKXB7bPXFeLPs9yfOJQQUWARm4+mca+p8Z1 05KVgmVXcrvLybhAYzGDeKEMPKs3tXL9rcYZ8MkpnCEdpoNYHQ9n+Wpu+zFTYlgO7CrO JK3w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JTO+TCCk; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-47927-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47927-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=1; AJvYcCU+/Jbv3cDjMVVnctnB2nx5iizjOiN3azJvtpwUZQj0exDMZNjjpWJyG1w4sCiSDRGd0B2PfpPMABvDppGG4A3UGTnY0mosMPpoCwSYKQ== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id di25-20020a056402319900b0055f00aa7576si3886208edb.259.2024.02.01.02.03.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 02:03:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-47927-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JTO+TCCk; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-47927-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47927-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 80F1C1F2B12E for ; Thu, 1 Feb 2024 10:03:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9545B15B10E; Thu, 1 Feb 2024 10:03:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="JTO+TCCk" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0FB064DA0A for ; Thu, 1 Feb 2024 10:03:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706781805; cv=none; b=LGDT+jPcThxv/qebHBZXRtBFHiTnmKkQ5jQHW3H+KRNaqJ9+aG9065qQTqAQ5UkT8KprikDsOvCQXDyxVVg1iZQXEb61vqCmdpKLWD3SHD1+kuRMUYX3t62JA+FZvPaxLwTnhCTL3wItnYyqhh//AMO3IT88EtYqeW9wvMtjmhc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706781805; c=relaxed/simple; bh=SMbbGGWUmvD7XTGC4Ymv5iB6mMaT4d+KU3zA8ododTc=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=Jf6N+nLIK9HayWRpcTHE1LggLdVlKpo+msjr86ai3jpYbne3HcKV7pwfMK0WBlrEM0ujrdY28XbU7dze9IHDowopA0D2waMPX96QtvLHsv3yvjpcFEIlvA0/RjIZw45H/tUsUM7xUWePqJ+kglOX7TjtuTO2V/dbeRDPsdymNKc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=JTO+TCCk; arc=none smtp.client-ip=198.175.65.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1706781803; x=1738317803; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=SMbbGGWUmvD7XTGC4Ymv5iB6mMaT4d+KU3zA8ododTc=; b=JTO+TCCkWHeijeH1wfaj8IlzyBmOdjSORpbwhPjOOOg96kGdZxRv+2Mu 3TgpWKRv6LKicJXr4e5S5X+1NSO9Clc9o9BEIiXbbRtHZzXkGq53yhr0P wXdz2to1or/P7hgSJnNkyR6WQRFqnIhbyiz3mxsGnuZ5GUi4ymAK8jhFS FQrKqPOBrWiDmtOMo3O/A3Rdw4/vUEvldk0EDT6YIIIZpZ8eKLCi8+82n lD+nCsxY+7dDlnoD707jgBOzRNSxTRRUHIMql6SEBF4rroqPw4aha6CDN +9NnmLZ/u+7tFAHeaZkd9YtJcI2HwmuubUsi2WGsNtQI2xRA5fJe/QeEQ A==; X-IronPort-AV: E=McAfee;i="6600,9927,10969"; a="41742" X-IronPort-AV: E=Sophos;i="6.05,234,1701158400"; d="scan'208";a="41742" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2024 02:03:22 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,234,1701158400"; d="scan'208";a="42236" Received: from aragners-mobl.ger.corp.intel.com (HELO localhost) ([10.252.43.111]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2024 02:03:18 -0800 From: Jani Nikula To: Cong Liu , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter Cc: Cong Liu , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: Re: [PATCH] drm/modes: Replace deprecated simple_strtol with kstrtol In-Reply-To: <20240201070226.3292315-1-liucong2@kylinos.cn> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <20240201070226.3292315-1-liucong2@kylinos.cn> Date: Thu, 01 Feb 2024 12:03:15 +0200 Message-ID: <87frych57g.fsf@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain On Thu, 01 Feb 2024, Cong Liu wrote: > This patch replaces the use of the deprecated simple_strtol [1] function > in the drm_modes.c file with the recommended kstrtol function. This change > improves error handling and boundary checks. > > [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#simple-strtol-simple-strtoll-simple-strtoul-simple-strtoull > > Signed-off-by: Cong Liu This is completely wrong, and obviously not tested at all. The recommended replacements are *not* drop-in replacements. Look into the documentation of the functions. BR, Jani. > --- > drivers/gpu/drm/drm_modes.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c > index 893f52ee4926..fce0fb1df9b2 100644 > --- a/drivers/gpu/drm/drm_modes.c > +++ b/drivers/gpu/drm/drm_modes.c > @@ -1942,7 +1942,7 @@ static int drm_mode_parse_cmdline_bpp(const char *str, char **end_ptr, > return -EINVAL; > > str++; > - bpp = simple_strtol(str, end_ptr, 10); > + bpp = kstrtol(str, end_ptr, 10); > if (*end_ptr == str) > return -EINVAL; > > @@ -1961,7 +1961,7 @@ static int drm_mode_parse_cmdline_refresh(const char *str, char **end_ptr, > return -EINVAL; > > str++; > - refresh = simple_strtol(str, end_ptr, 10); > + refresh = kstrtol(str, end_ptr, 10); > if (*end_ptr == str) > return -EINVAL; > > @@ -2033,7 +2033,7 @@ static int drm_mode_parse_cmdline_res_mode(const char *str, unsigned int length, > int remaining, i; > char *end_ptr; > > - xres = simple_strtol(str, &end_ptr, 10); > + xres = kstrtol(str, &end_ptr, 10); > if (end_ptr == str) > return -EINVAL; > > @@ -2042,7 +2042,7 @@ static int drm_mode_parse_cmdline_res_mode(const char *str, unsigned int length, > end_ptr++; > > str = end_ptr; > - yres = simple_strtol(str, &end_ptr, 10); > + yres = kstrtol(str, &end_ptr, 10); > if (end_ptr == str) > return -EINVAL; > > @@ -2100,7 +2100,7 @@ static int drm_mode_parse_cmdline_int(const char *delim, unsigned int *int_ret) > return -EINVAL; > > value = delim + 1; > - *int_ret = simple_strtol(value, &endp, 10); > + *int_ret = kstrtol(value, &endp, 10); > > /* Make sure we have parsed something */ > if (endp == value) -- Jani Nikula, Intel