Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp612261rdb; Thu, 15 Feb 2024 09:44:42 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU4pr2KB+tAJAF9CS0wvP7GsqI+bXi23JbOq71W3KNPrshgqD79P6ojcAx98ewEV8Uv/i3jvs30eYdi/kSQxPE9OjbHpaj0/bWwCHa8bQ== X-Google-Smtp-Source: AGHT+IEo+x6xYB2djn0DXUf8JMRTH08qjKnz1FnepdZFfDePMH0lfW9wLeE/DLcUgo9HnQKGIybd X-Received: by 2002:a17:90a:a008:b0:297:24b8:6dd4 with SMTP id q8-20020a17090aa00800b0029724b86dd4mr2318080pjp.21.1708019081761; Thu, 15 Feb 2024 09:44:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708019081; cv=pass; d=google.com; s=arc-20160816; b=eo7Ty6tO2NWjlQh/Ct+jGeQjPwPKyUrR+PXUbTRgA06XLPur9JJcb4uqzHbnRB3MS+ s+7GETlJUTfKtRUyNw1PWsH+hlM54WKOGAJJynolYerJ3gi8G9VGeGPEGdG0mnE0F21B nyncfFxJbwDMy6k0QqHlTRAmf8zqJmGPFCh6f3FMLbJppC45NiliZcwdyYADuW9dHJFM LcD6+6zWASdb2zlLlJA2oc5yotU94MC9gXf2jLt29TPgVNy3aiq+ESTFwNCHFVtPdlPB /CorDUV9L0UwQx6Hqu5Pge3fOHqf6DPWySlhH+SqcUH7zu1QYOhc/NNwecq5NaiRu8xx 4IYg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=organization:in-reply-to:content-transfer-encoding :content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:references:message-id:subject:cc:to:from:date :dkim-signature; bh=UZQk7Fn1l7sGImtBosfXlZQPDm3et/v6G/X+eVqXpVo=; fh=rh7qx8KmKaeRTF67Mio9uZ4mTtS4efHIm+qsLFrg9qE=; b=Fdkqrw5ARMFVw+noJqJQO57ROYpRSzcOvOPbMMZDVI4hbUBHkm8TGxv5bpqlwdl/z2 FCYCnn4fSmdV1HzlIeTC0SB9SSN5fIL0O1AFddEue3HPD2msdBA6T6i86bR6OGp3T3Eu jlARAczdrFIf8e5NTkzqfLvKtKJUTKpwzUmOUOeu05FloN+lTa/B6e8mvQ7sfmmrt0JO c8W7AqGhk+5UGzb6SeCe9ug4iV+SWzf+OzR69LloCPQL7I+stZURkfTx655OIyosI6bB dKbVYV7iWeerbw94g4SZqT5vcy6J8hYU5VSTxYrYPzPL/eAzYP0sM4xFsHVX4ynmbe/i j/tQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hyTYVfLZ; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-67037-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67037-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id px1-20020a17090b270100b0029895ac67d0si1568804pjb.105.2024.02.15.09.44.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 09:44:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67037-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hyTYVfLZ; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-67037-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67037-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 5FDE3293279 for ; Thu, 15 Feb 2024 13:58:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1870812FF7C; Thu, 15 Feb 2024 13:58:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="hyTYVfLZ" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) (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 B30FA131E24; Thu, 15 Feb 2024 13:58:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.15 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708005485; cv=none; b=B5lzLJzLbClnd82v+4S85sVeDdbTonO/UURBIEKKoVZH67i+3bIlllRJS03N0RRAWD2w2ie9pzIlQA6XcKWVJ86W75sWYNFZgA65hcmPDUMqlCNJoC5VxXVB6GAxQqO0TNvBGT3nv8qu2L/ePj/CmIZ5EFGXSBS+3Y5a6Kp3aSM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708005485; c=relaxed/simple; bh=UPKpN7nqui4ysDnCGreHX8nzGj9sjALQGsYZp/dmEZs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=pDPwniKKDUxQ8UrZyrekUC38IGOOjVii+gQC0Xotn5fmZnIh9EqlAgME+SH8y5pTqoqSVnd7o+oclj4FuYJ77YclVeivhiFUc5lrlqR16d+j7es8CxyxRG+i5IU5C0YSKt/RjwsDojEwQb6lfi3OQwqHGT1p+R9GMYnyy9cOSzo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=hyTYVfLZ; arc=none smtp.client-ip=198.175.65.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708005484; x=1739541484; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=UPKpN7nqui4ysDnCGreHX8nzGj9sjALQGsYZp/dmEZs=; b=hyTYVfLZ/DXIYFtqk6ccCyYqpHZrxBOD2XQYZZRb3MAJcmAHrx46K1iA Kckb4cuMuMKQ4p2mn3wxstzhhdsmgVPs8ot8NcSeNNFLiIiiUHSCYkUl4 NtSXjJYgjG2TBmco35CILX6q3W0JQ47RjI2UqJEaFF86tNYGBKg8MO+xW Hz/njtzpUsYvB4zaG19YCp7NaLqYQfPwzgLXDopVGoVt0ktzhV1zP7xIK kSTuRDRdANDu7KUTwSJAl57LGuUdNigNgBhRzJNmtBZ2+Q8WDX8mWTM7M QIDtyGCz8UzTbvhORapVVph5kNj3ATwzqldQQEOlY0ZgqltpETw5G98z1 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10984"; a="5920052" X-IronPort-AV: E=Sophos;i="6.06,161,1705392000"; d="scan'208";a="5920052" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Feb 2024 05:58:03 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10984"; a="912169588" X-IronPort-AV: E=Sophos;i="6.06,161,1705392000"; d="scan'208";a="912169588" Received: from smile.fi.intel.com ([10.237.72.54]) by fmsmga002.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Feb 2024 05:58:01 -0800 Received: from andy by smile.fi.intel.com with local (Exim 4.97) (envelope-from ) id 1racFS-00000004o05-1lJP; Thu, 15 Feb 2024 15:57:58 +0200 Date: Thu, 15 Feb 2024 15:57:58 +0200 From: Andy Shevchenko To: Geert Uytterhoeven Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Rob Herring , Krzysztof Kozlowski , Conor Dooley , Robin van der Gracht , Paul Burton Subject: Re: [PATCH v2 10/15] auxdisplay: linedisp: Provide a small buffer in the struct linedisp Message-ID: References: <20240212170423.2860895-1-andriy.shevchenko@linux.intel.com> <20240212170423.2860895-11-andriy.shevchenko@linux.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; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo On Thu, Feb 15, 2024 at 01:33:29PM +0100, Geert Uytterhoeven wrote: > On Thu, Feb 15, 2024 at 1:19 PM Andy Shevchenko > wrote: > > On Thu, Feb 15, 2024 at 02:17:00PM +0200, Andy Shevchenko wrote: > > > On Thu, Feb 15, 2024 at 11:40:44AM +0100, Geert Uytterhoeven wrote: > > > > On Mon, Feb 12, 2024 at 6:04 PM Andy Shevchenko > > > > wrote: > > > > > + linedisp->buf = buf ? buf : linedisp->curr; > > > > > + linedisp->num_chars = buf ? num_chars : min(num_chars, LINEDISP_DEFAULT_BUF_SZ); > > > > > > > > I think it would be safer to return an error if buf == NULL and > > > > num_chars < LINEDISP_DEFAULT_BUF_SZ. > > > > > > I think you meant >= ? > > Oops, yes/ > > > > > > > > Else a careless driver that doesn't check linedisp->num_chars might > > > > overflow the buffer. > > > > > > Okay, check has been added. > > > > Hold on, but I have min() being called, isn't it enough? > > Yes you have. > > A careless driver might not use linedisp->num_chars later, but instead > just hardcode e.g. memcpy(linedisp->buf, source, LARGE_BUF_SIZE). I see the point, yes, we need an additional check. -- With Best Regards, Andy Shevchenko