From mboxrd@z Thu Jan 1 00:00:00 1970 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="hyTYVfLZ" 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: devicetree@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