From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E2FC81E2614 for ; Mon, 23 Mar 2026 13:18:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774271891; cv=none; b=noIG0eVEEu/exItdCe/ioywxiaULJVp2W2ytYM+tfdxFI5RiblluhpPHn2o+rijLkHOuc5PbpLG2Xz2l2J332+TAV9kadvvSZPMgaG42aK55+XT6QDcztqd6Pw09btuYhDxAPEj30hGA635uHa4yKjF3y0hpK/FY3P7IP885GIA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774271891; c=relaxed/simple; bh=WTc1bsLGXSiZektMWAXMrNEISq1ztjcmpUgGfApGu5w=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=lP0GlmkWRxgDiTjbJR/0ap8zuHtb9sGoxMayykiH5TCyVj4dNIjNNh3/J4Lz73Dlk1IUhqyF4mHKxn3IhILDqFHO58616m4x67MGOuLjbbfUza2IBUeB8gkNcPy4NLv9cRgMUHRy5slTVbIK4eQ+RRhaeDgXyAGsEixlHj2ryVo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=nNDXkRcF; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="nNDXkRcF" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-48334ee0aeaso1015995e9.1 for ; Mon, 23 Mar 2026 06:18:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1774271888; x=1774876688; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=K7/zCsfa6JPvW8FuHtrrROxnJKdhhrcvUQ8XhWVGxEU=; b=nNDXkRcFEbYCfS8T+MrR5er2FrKPG4oS/sqVJjkGwyzkjLluQTqIV1PpeBpWc49kvH /ajfoQSzcPQkLpKajWQT9iot3aPVED3bvvlM2JR+XzaA6DHc8cyCOqxE6KZHiAnYvYNl iiUfHjHA7cz3Sa5IB1g5telTNCSN1wIICUYKgdMXaY8n8n+G694WpXfk9C4cXFAfgn27 4SBo9dOCGLmlHFrW0yfokP/wiPldb/gMtUni+tNP4/pv+l2E6YWHNsAwsTsrYjo2nfK5 empsKueCYDPmK9js/pIBZAXQBY1oHLtqnDJiOa04kra+OgJy9XOYMUHj0fb4G3kfYpEe JoEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774271888; x=1774876688; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=K7/zCsfa6JPvW8FuHtrrROxnJKdhhrcvUQ8XhWVGxEU=; b=haDqE5jVw/UyrahATTFW8390PxHrokU69FhZxKttJJASdRscOun0doba1W1dPrXQQd stLcLjlx5VubYv15GDrWUkTWjnd7SXMAGkIWz9Q7w1B2xyxCJ+qN3MDQxmo6Cs8GXW47 Iir9Sg+j3+jbOj6M9tF0iuXcPx7dF91WHsidpzuvvCcMXhBqM7VQRFMG3Wn8vvCSPS/d BCY3mYwo7pgfvC4KxUdDjXEUY+NzKP/H4n7E89B1IwT7kTe+/Trut7n0uocrYVGDdWxc oUpMWeI6XtAa/GM6CpoaURtRf+tr59V7U5MQLtUjwKBfv3zZPZUDoGqe4JQbcD8dws2H 0EHw== X-Forwarded-Encrypted: i=1; AJvYcCUqo2FzRoTeEG3daXPU0zJoXi8c6hLQPmHgw1pFLjIm9qrAJlxUV35wlNA2aH1MkQBuPJXdJLOamojjcEo=@vger.kernel.org X-Gm-Message-State: AOJu0Yxvjv7yL/L1FlvKQToZ2Ef0m0hep0wZ0+VvKg2Uv5Cz+yXBjAcd 2+ih6rzPryEVtUxH+yjq4THaT6Ge62xGN3AlBzQbyhGNldCILl+aiMueCO1Uj0rAIxA= X-Gm-Gg: ATEYQzxve7y+sI0tif3dSfQORr8lHvDvu+ye/N2PiPkNaoZu7jTxPttwPmS5ujubKbi AC5NJ+EqF4HdsDkDgxuHTMIRT1ow4T8XjW6GmLFJ1ADglActT5O0MpOHPDYlYX5Vx6y22dcKQSB wXT/GQ+m9CPnyOElBT+vOBq9Z34O7GQA6M+L4cki2vvoNhKOwy4hY1gL9Pn+n2l/8Koy3qkdioD mlIG5JRk34hn/oolra98EA4TiXfA/+VY6wlfMrnJRi24ZQ+yggF+J4AvqjCgWxY5Z6FNGyDv09h M1Y8y4wgJMz/+00chzeaB5FSX8BisyikYzSLZ1AOM8ARMR36VnnD3Oi6fm8Bi0LxisOMmauPnHc 9SmltslXTjxOfeF6IVUpzroeo7FbK7jol2RM1IHEpn582JfJBgOFuysgX+XcjFGOAO2XQk/czeS QV4SBZFn/2Xf74IEdhV8Kk8Vs5XFYS X-Received: by 2002:a05:600c:4ed1:b0:47d:8479:78d5 with SMTP id 5b1f17b1804b1-486fede7230mr180611445e9.7.1774271888163; Mon, 23 Mar 2026 06:18:08 -0700 (PDT) Received: from localhost ([196.207.164.177]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43b646b0d3dsm28159777f8f.16.2026.03.23.06.18.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Mar 2026 06:18:07 -0700 (PDT) Date: Mon, 23 Mar 2026 16:18:04 +0300 From: Dan Carpenter To: Pengpeng Hou Cc: andy@kernel.org, hansg@kernel.org, mchehab@kernel.org, sakari.ailus@linux.intel.com, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-staging@lists.linux.dev Subject: Re: [PATCH] media: atomisp: ov2722: flush buffered writes before they overflow Message-ID: References: <20260323121730.75257-1-pengpeng@iscas.ac.cn> 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=us-ascii Content-Disposition: inline In-Reply-To: <20260323121730.75257-1-pengpeng@iscas.ac.cn> On Mon, Mar 23, 2026 at 08:17:30PM +0800, Pengpeng Hou wrote: > __ov2722_buf_reg_array() appends 8-bit or 16-bit values to the buffered > register-write payload and only checks whether it should flush after the > new value has already been written. When ctrl->index points at the last > byte of the fixed 30-byte data buffer and the next register is 16-bit, > the helper writes one byte past the end of the local buffer before the > flush threshold check runs. > > Check whether the next value fits before writing it. If not, flush the > current buffered write first and then append the new value. > > Signed-off-by: Pengpeng Hou The patch is wrong and just adds dead code. The function is called in a loop. The buffer has 30 bytes. We write either 1 or 2 bytes. When the index reaches 28 at the end of the function then we write the buffer and reset the ctrl->index to zero. So the new check for if ctrl->index is larger than 28 or 29 at the start of the function will never trigger. We never actually write to the last two bytes in the array. So the original code is off by one in that sense, I suppose? The >= should be > as you wrote your code. Not a huge deal? This patch has no information about how the bug was identified or how the patch tested. If you put a note to say that "This was found via static analysis" it changes how we review the code. Or a note to say that "this has not been tested" then that also is good information for reviewers. There is also no Fixes tag. Adding a Fixes tag helps you figure out how the bug was introduced or what the original author may have been thinking. It's also necessary for the review process and the stable process. regards, dan carpenter