From nobody Sun Feb 8 10:04:10 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 From nobody Sun Feb 8 10:04:10 2026 Received: from mail-lf1-f67.google.com (mail-lf1-f67.google.com [209.85.167.67]) (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 CB059342CB1 for ; Wed, 14 Jan 2026 10:32:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.67 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768386750; cv=none; b=ar6R36yxBLq/OUIwXvpOsilD/HKYmmsXnOpY7Qe2m6IP4WOKGPUHrtPiPhDQXi08YepmvAtJKFY2E++Kjye1mwpct8CAPAHGMJzvcyMcKNvIqfR1Pr70Z3fDFSKb29tEeAbomk4RaEKM02t1mW68rzR2lBjixj0NOkRD7b6uP1U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768386750; c=relaxed/simple; bh=fLDCCM5+VCZGP7XXhipvWTv4MC0kLaeDD1P3yoqPOXc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=c/kqZsyN/GF/2NlVVLhYBHxHFrlbRg0K3A5GUAQg8j7D3cTQw++ZRsYVV+8tNXlK838MM6v1Ssqn3VFs+k03kvCand+MoN3XMV3Cax3LKQ1G05d83yzUPeHi2X8g109v8D19rNvNB66UXxdDltM2awXSNUgSdQMfmYmiVOqKgTE= 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=HINSe01x; arc=none smtp.client-ip=209.85.167.67 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="HINSe01x" Received: by mail-lf1-f67.google.com with SMTP id 2adb3069b0e04-59b6f59c4f5so9774685e87.3 for ; Wed, 14 Jan 2026 02:32:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1768386744; x=1768991544; 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=hiAWrXH6x8EcXbUPmtbuPYc6WD9v4tNKnw7z9A4t3d0=; b=HINSe01xosE8PcxbLvhfhZ9sSg53ycT3mscygecOm1/ox5gsDU9fI3WjMp4EcATFWG 3gYYUKDzrIgvOHsxwXhkthTNWRuocmXHuXQcyAFtWJwwln+Ssufv9rs0IDu1fZMA6Ofd u3o+mOryX0CXImuF8jLJaYwWCZTMDYQ02K3wM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768386744; x=1768991544; 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=hiAWrXH6x8EcXbUPmtbuPYc6WD9v4tNKnw7z9A4t3d0=; b=UaGjuEtGEgTgh5Sm9sm2YlaNnP7LPNfv2mtE+byqE2NqRxahSkdjP754HFiYYWTT9C 3jsWsgNwVPnZJ/WEBOjfNyRmNWKAL1fhSJTlDHrWtkt63M5d7+XEiGapoWF5sxtV9sKf DxlFZ2ADPik48Qo3KvCjA2sIMJZTIFvsP2uthMFKOInz0k6NNBxlSoVrYXzAoIgEyofk 3N8dmsmv9uYodQcfKTYlzA2vDx0brPGa0lUIholsPIhiI0IXiRuPD3yY7osPtYYEO7tW BY1rLFwxI2jxdKFuH3+JE8SscCqUCUjbP9i0tjHMO4Z98WP88ir79fshF6qj9HrSrDNG Ih+Q== X-Forwarded-Encrypted: i=1; AJvYcCXFDGynzEtrR3YKS4RsaS4HPJoODj2EusvSLp40DbRPHiQJ1+p9gaW+8MMzoPCj6rFwWNp3f6KxxnFn4/Q=@vger.kernel.org X-Gm-Message-State: AOJu0Yx4ksdiPlL8sa5yLih5KmZo5I7e9dxQ8tVpp4M4cZdGfRRERty5 6M3UI4z+d4obPImQER1S1FNPJ0Jmco21DMKbvxsGgrL3K5ZOXFt0uhWc5jZZNqBtRw== X-Gm-Gg: AY/fxX4ZAaT9gTwqeTglQHy6HROeq8EP7ieo+nj2k8pxIp4zF1p893WUSEwNciri7xK a7DzqfBmRZId+qWBNUs6jmK2JAf09RXdvFCl8rN6aDaBYKcvLYo9fr2KLkktI3M8ZQpeJ3Na/jP xJQD56002GKzRfO+7E1QpeL1OJDffwnNB6+Um6hHZYzZMXNKsqzoxEWT7v/rMs4OUjENxZtr6V8 tVP59XDdye7paovFtC84ff3B8cqkiIwRanHmj8n18c2vXngftEn2zs0odJ/fxLGDc6ztrweAgst eap7BE3t3ZvnmkAR9SHRG3rNT/SsI3hyyJovN81iDI3wnwLqMo3S/h/FNXNQgebzmD0Ql3mMveU /WFVdZQY8oM1RowURoHHdfH3jHX6RgGG9mIJ53DEeOh9S0h/NzOOGwiutCsY0ahB92KG/b1OCaz qo/TaJN/2CZDPQh8HcRdgY9B9zDYDzQUaECssASYENR5PeSuvOfdeGtr64tycQNVo6hit0rw== X-Received: by 2002:a05:6512:10cd:b0:57a:2be1:d779 with SMTP id 2adb3069b0e04-59ba15502b6mr638673e87.31.1768386743782; Wed, 14 Jan 2026 02:32:23 -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.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jan 2026 02:32:20 -0800 (PST) From: Ricardo Ribalda Date: Wed, 14 Jan 2026 10:32:14 +0000 Subject: [PATCH 2/3] media: uvcvideo: Pass allocation size directly to uvc_alloc_urb_buffer 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-2-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 X-Mailer: b4 0.14.2 The uvc_alloc_urb_buffer() function implicitly depended on the stream->urb_size field, which was set by its caller, uvc_alloc_urb_buffers(). This implicit data flow makes the code harder to follow. More importantly, stream->urb_size was updated within the allocation loop before the allocation was confirmed to be successful. If the allocation failed, the stream object would be left with a urb_size that doesn't correspond to valid, allocated URB buffers. Refactor uvc_alloc_urb_buffer() to accept the buffer size as an explicit argument. This makes the function's dependencies clear and improves the robustness of the error handling path. The stream->urb_size is now set only after a complete and successful allocation. This is a pure refactoring and introduces no functional changes. Signed-off-by: Ricardo Ribalda Reviewed-by: Laurent Pinchart --- drivers/media/usb/uvc/uvc_video.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_= video.c index ec76595f3c4be0f49b798ec663d6855d78ab21c4..59eb95a4b70c05b1a12986e908b= 7e9979b064fd0 100644 --- a/drivers/media/usb/uvc/uvc_video.c +++ b/drivers/media/usb/uvc/uvc_video.c @@ -1771,12 +1771,13 @@ static void uvc_free_urb_buffers(struct uvc_streami= ng *stream) } =20 static bool uvc_alloc_urb_buffer(struct uvc_streaming *stream, - struct uvc_urb *uvc_urb, gfp_t gfp_flags) + struct uvc_urb *uvc_urb, unsigned int size, + gfp_t gfp_flags) { struct usb_device *udev =3D stream->dev->udev; =20 - uvc_urb->buffer =3D usb_alloc_noncoherent(udev, stream->urb_size, - gfp_flags, &uvc_urb->dma, + uvc_urb->buffer =3D usb_alloc_noncoherent(udev, size, gfp_flags, + &uvc_urb->dma, uvc_stream_dir(stream), &uvc_urb->sgt); return !!uvc_urb->buffer; @@ -1813,12 +1814,13 @@ static int uvc_alloc_urb_buffers(struct uvc_streami= ng *stream, =20 /* Retry allocations until one succeed. */ for (; npackets > 0; npackets /=3D 2) { - stream->urb_size =3D psize * npackets; + unsigned int urb_size =3D psize * npackets; =20 for (i =3D 0; i < UVC_URBS; ++i) { struct uvc_urb *uvc_urb =3D &stream->uvc_urb[i]; =20 - if (!uvc_alloc_urb_buffer(stream, uvc_urb, gfp_flags)) { + if (!uvc_alloc_urb_buffer(stream, uvc_urb, urb_size, + gfp_flags)) { uvc_free_urb_buffers(stream); break; } @@ -1830,6 +1832,7 @@ static int uvc_alloc_urb_buffers(struct uvc_streaming= *stream, uvc_dbg(stream->dev, VIDEO, "Allocated %u URB buffers of %ux%u bytes each\n", UVC_URBS, npackets, psize); + stream->urb_size =3D urb_size; return npackets; } } @@ -1837,7 +1840,6 @@ 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 From nobody Sun Feb 8 10:04:10 2026 Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) (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 F1CC338E12E for ; Wed, 14 Jan 2026 10:32:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768386756; cv=none; b=SIUovj/hhS6L66xzRcf5+gBWrVXGhme/JaUjinJGe1+kikvlmGKg5+y+nm/fr/NP+TuPiIteg450HrQCUlbRdnSO6iuEEP/2O+qtjpFxdUT0odj4ToWGuyPlrOtXAHDu8R1EVEe0Qv+z7QBqukN6qldFVdupEA8DFv3MxRqqdyg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768386756; c=relaxed/simple; bh=pCYTDrzs5PZKkR4SCnzv6Jrv3cKoqYJo/QJ8RXsQx54=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=PmvLLfhCfdlGJkZdACDTuPumdyAOak8yvJJwiK2IXgQgPnTIUVEnRqrpE5xnAVGN5LTyVcqfnuBd/8+xo68zE0n5/ckEO8FIw6nMCQZ/Psvo0Bzgio49W/FlPZruARE6PVTV+mK7pGtJGWNCV1p8ABW9H9A9UkSa3rUuiWSkvJM= 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=HCyKEZFb; arc=none smtp.client-ip=209.85.167.44 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="HCyKEZFb" Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-59b8466b4a8so3922077e87.1 for ; Wed, 14 Jan 2026 02:32:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1768386748; x=1768991548; 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=OwbbUWw6Vs8xgqtHC1ZesMYsqb+WhuYt/f5FK2CbCH8=; b=HCyKEZFbNUo7U/rWeKmGUH/4JizI02hxkNEoEAJe4UW77M1dRHrmopEPWwcpDswYLg +YblHadXkss6GpurFE3Lg7ZkCOIU8+7EnU98SpSIk4rspQCy8LKGdFev5UyxNytMuCJh hrzYQKxGzz4hb6hLGQNeqvEhqehWa4qpitC3w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768386748; x=1768991548; 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=OwbbUWw6Vs8xgqtHC1ZesMYsqb+WhuYt/f5FK2CbCH8=; b=bsH1TpKgXpQJHkjnQIdBh5D6qWvllW/vHNbSc0upwAtU7QzzpnmEMKhbxm/oVLXcfn VwfbNzpZ6rqSR/Gc4tU6k1JKazQtZTMirBwM4UIUxbitCsFRRLI6z0Yjnz2l+KiW0A8j CTgwosuIrhmfpG1kCo8AePXG7st9shu/SRoxL3quUopG+nKNaSmwVXqstemibm9+TnnA oxT3PYVnGltp1Gukx9z2LDuJm5eGFhOGOyVcWv9bZlow99lKaGjUJXAVqgENiztO9Qb5 owQDJoAuQOXj5/G+brJRAz3dvjioBJc/6HB3N5sPPg6YSVbqe1e5AMW2cEd/wd5H0niU GRXw== X-Forwarded-Encrypted: i=1; AJvYcCX260xRNH/rXN1qKmnOdce4ntB6f+O17tnE9y1kAICt9woKECPDnojbwgb+rODcMlFBKoYKMCV9RR6wul0=@vger.kernel.org X-Gm-Message-State: AOJu0YxuXMsNqSG1AzGuBLa2fxPTNouSP6/EB44wO9Mj00HuW9fsE61B 8jeFtx8lC9CEmwrYN2qFarly6zEEExU5WJLUyawGhG3Y6zB1//K0KrGNqOtK691jFQ== X-Gm-Gg: AY/fxX5KEDJKUeRuh46HxEqjeAd4KkzhduaunSP1PQqpy837fkAF5iydsBe5GVSTg6u ToGsZHa56qbeYjlpyD1k5F38BJNN9BDVqB4NLNVMNenmlewpyeZbKA0KTI9kRPxhiRcqPtdy1Mw j7MNvpnQlQ6jVuFD9Y5RJGkV/lED8otzYKFIJfM1bVifQiKb2GpMts84t8Z0TEq15Cik+nlOLUn 2OvydujMk5cge7SAfMGc/lUWSDvKQkwrtk441fozzARp2e5zX/I6dO0+XBSOOiT259ZqtRaDxwV KFDUgOYADBo53ehzO+sxY/YZSrD9QF5re0b9C113cymGCZjudubNBOmqcsusSGyKL2rDjYnCJlr PI/xV1W3DJ6l3nYJ8CHLVOs1zkJT8F4k6QrvL3r+zI2ALuJpKPRq7SV6jnXP4bg81hLz5HpCr0L h/8vFi40UIWDFJ6KQIPc15nJ1m555KKCI9Lc3WUvNO2/Z1rsiqE2lSSIWt6yDEk41DFMeWsg== X-Received: by 2002:a05:6512:110e:b0:598:f262:1658 with SMTP id 2adb3069b0e04-59ba0f78c4emr643858e87.34.1768386747665; Wed, 14 Jan 2026 02:32:27 -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.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jan 2026 02:32:24 -0800 (PST) From: Ricardo Ribalda Date: Wed, 14 Jan 2026 10:32:15 +0000 Subject: [PATCH 3/3] media: uvcvideo: use min() for npacket calculation 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-3-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 X-Mailer: b4 0.14.2 Make the code slightly more appealing by making use of min(). There shall not be any functional change from this patch. Signed-off-by: Ricardo Ribalda --- drivers/media/usb/uvc/uvc_video.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_= video.c index 59eb95a4b70c05b1a12986e908b7e9979b064fd0..db02080f15772e0bc1d5cfcadd3= 2463f4e6ea045 100644 --- a/drivers/media/usb/uvc/uvc_video.c +++ b/drivers/media/usb/uvc/uvc_video.c @@ -1808,9 +1808,7 @@ static int uvc_alloc_urb_buffers(struct uvc_streaming= *stream, * Compute the number of packets. Bulk endpoints might transfer UVC * payloads across multiple URBs. */ - npackets =3D DIV_ROUND_UP(size, psize); - if (npackets > UVC_MAX_PACKETS) - npackets =3D UVC_MAX_PACKETS; + npackets =3D min(UVC_MAX_PACKETS, DIV_ROUND_UP(size, psize)); =20 /* Retry allocations until one succeed. */ for (; npackets > 0; npackets /=3D 2) { --=20 2.52.0.457.g6b5491de43-goog