From nobody Mon Feb 9 11:47:14 2026 Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) (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 EEF6B38B9A3 for ; Wed, 14 Jan 2026 10:32:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768386747; cv=none; b=HOUGO+v/0ANGyhluUFCMHZym9vllK79SwWW1X1RWMUulxvIatgegoQtdngNLT9wyW/cUZLG1RE5Zz1tffuJjtI+5T4yzzLddoX/xX4339FvA3ZWuO3uNzmsnN+6hGLtMbnabfYeZnNyAn0WHaIs2J5GjBZQHLvSsvRwFP1aw6zo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768386747; c=relaxed/simple; bh=SHynUnvM3NYGdVKJkmlJNrHMRItgetV0ce7T9jNI6UM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mOLrFWNB28/ICFHdKfxLVt2mjx4pnWyWKhjz+VC2NJhchy+2FzFHFCwiMfTybDLC2WL78gLNl7zHXCm0AasK6N7PFf030C8VvBwjcPaF+c5lxXKR4Bl6mLmgcoBUwvJPxsGjLBADFD4l++R2V4y/7pyday/3jI1TpkkScCqc6Ho= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=LQP2o/ay; arc=none smtp.client-ip=209.85.167.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="LQP2o/ay" Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-59b6df3d6b4so8774375e87.0 for ; Wed, 14 Jan 2026 02:32:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1768386740; x=1768991540; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=JPZ/6SpG9mbhlb5la0esyshmoTDD8GRw30UpCzvHfqY=; b=LQP2o/ayzVvdTZnrF1PLLcEsgJ5YkGEKTl5QtlOZEnEnZIyaDn0hoHfzluOb3/NO/K pfMaDttTuggNk2TISfwrc2efKsEUVJi7tnRRKmrNp2oxKSoBHag2zKiCG5C7QukVwyna oLFH/v8BNWowM9syif0PFSnpiaKCd+n1u/pug= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768386740; x=1768991540; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=JPZ/6SpG9mbhlb5la0esyshmoTDD8GRw30UpCzvHfqY=; b=xGgkBneW+nbzM3OP2hAr+gmf0grQJZ6IK+ALN0csup1uSjBV9FZJ9WKmEr1wsgmE3Q GPbqz7nwI4YWh25cEhyDdirJBN7aUry6yHWuwI4mIzdqeuA9MC8zOoW0oZE3C9ljYGvb BTKjmL5BmtLDL/AEOMaChhZUrWtRO6HFWgPQBGfN6+UEpON5rKsB/tejq01Vmy9Skrip 2nGvYb3+xDAKH+qOyKY9bN/BlKupqSLe0AmymPqqdYbspHLe6zFNVYi2lxu2+Mx+huUu EHcyjhB1PYjuNpzrC6JGZ8/uxIdQtVx/sM3jbCX+WkoGgjPO/m2MIp8cEiy2L2qF52YW 04NQ== X-Forwarded-Encrypted: i=1; AJvYcCXwVj7V+4MMGrauPzhquUmVRIAz5zUwiBn6gQkpQ4OxyNIkilHaERLVDpSKXTtonJA/a4ww5kmYj0+araY=@vger.kernel.org X-Gm-Message-State: AOJu0YxOIpJMLwRCuvxpBqv+e9REyMTdsN+wG/ScVHpI4GP7zB350lnd rZZ62Kf8qDBBdpBtPezrAS3R9uDQ5IH7u77EdbVV6oZGShTjOPp4Xb2GxREeGpZhUQ== X-Gm-Gg: AY/fxX6yUVcOQX9uxnXkzIAjdZS1YIFpzPu+1oJ3TLOngciyENTbjFke3wp9xELAEgq bId2i5p1EEvQxxOPAqQl/scgdFJ5/x2zZ4fvPohFtggerdZLXB8OwomzBCnIBX46BaIww3MoBmb 3jdHmWwWCQAV+3Etz4QdQe4aHbtA9+M0iUoIPUezLylGa3mBXW/xcv+oJjWicdLza4JZhu5LCEp VZgFH1Hoz3sfYOdzht0Mawh/Fo/OPMBAH3YolMgstkjq9NAFM5sIEhC2rNWHOOJDOr1WeiEuhe2 A+IUBjCGkE8SwMjTTF6mZfZ5cZCw6ZTOO/ctsj0UBdDtBd1but5eR76OjQ9Sq/qihdL/P2Li2KN 4eUFjf4o2Pkr2bilhnBwNqI/nY6tI0JRJt36nWwjm6eilKmiq7wSH+FhUzJfDG5QHZNNSPKK+lB Rmx78omw5aRKNA3kIXrfwS3qXjjfl7j8XqKbIXVLal5TL14xrTlO6euH33dmi8WJs7htU4Tg== X-Received: by 2002:a05:6512:1286:b0:59b:7291:9cc2 with SMTP id 2adb3069b0e04-59ba174d8a6mr555446e87.37.1768386740374; Wed, 14 Jan 2026 02:32:20 -0800 (PST) Received: from ribalda.c.googlers.com (181.105.228.35.bc.googleusercontent.com. [35.228.105.181]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-59ba10411e5sm573981e87.61.2026.01.14.02.32.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jan 2026 02:32:15 -0800 (PST) From: Ricardo Ribalda Date: Wed, 14 Jan 2026 10:32:13 +0000 Subject: [PATCH 1/3] media: uvcvideo: Fix allocation for small frame sizes 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-Transfer-Encoding: quoted-printable Message-Id: <20260114-uvc-alloc-urb-v1-1-cedf3fb66711@chromium.org> References: <20260114-uvc-alloc-urb-v1-0-cedf3fb66711@chromium.org> In-Reply-To: <20260114-uvc-alloc-urb-v1-0-cedf3fb66711@chromium.org> To: Laurent Pinchart , Hans de Goede , Mauro Carvalho Chehab , Johannes Berg Cc: Laurent Pinchart , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Ricardo Ribalda , Itay Chamiel X-Mailer: b4 0.14.2 If a frame has size of less or equal than one packet size uvc_alloc_urb_buffers() is unable to allocate memory for it due to a off-by-one error. Fix the off-by-one-error and now that we are at it, make sure that stream->urb_size has always a valid value when we return from the function, even when an error happens. Fixes: efdc8a9585ce ("V4L/DVB (10295): uvcvideo: Retry URB buffers allocati= on when the system is low on memory.") Reported-by: Itay Chamiel Closes: https://lore.kernel.org/linux-media/CANiDSCsSoZf2LsCCoWAUbCg6tJT-yp= XR1B85aa6rAdMVYr2iBQ@mail.gmail.com/T/#t Co-developed-by: Itay Chamiel Signed-off-by: Itay Chamiel Signed-off-by: Ricardo Ribalda Reviewed-by: Laurent Pinchart --- drivers/media/usb/uvc/uvc_video.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_= video.c index 2094e059d7d39ac5a196cbbd58f9bc997f1c1557..ec76595f3c4be0f49b798ec663d= 6855d78ab21c4 100644 --- a/drivers/media/usb/uvc/uvc_video.c +++ b/drivers/media/usb/uvc/uvc_video.c @@ -1812,7 +1812,7 @@ static int uvc_alloc_urb_buffers(struct uvc_streaming= *stream, npackets =3D UVC_MAX_PACKETS; =20 /* Retry allocations until one succeed. */ - for (; npackets > 1; npackets /=3D 2) { + for (; npackets > 0; npackets /=3D 2) { stream->urb_size =3D psize * npackets; =20 for (i =3D 0; i < UVC_URBS; ++i) { @@ -1837,6 +1837,7 @@ static int uvc_alloc_urb_buffers(struct uvc_streaming= *stream, uvc_dbg(stream->dev, VIDEO, "Failed to allocate URB buffers (%u bytes per packet)\n", psize); + stream->urb_size =3D 0; return 0; } =20 --=20 2.52.0.457.g6b5491de43-goog