From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 811522FA62E; Tue, 17 Jun 2025 16:57:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750179458; cv=none; b=n3wXo9oCaXdKT+LagqGc0QPN7oZNgxPemk3phXg9EtwSP+RGITy4uF+vMtVZGXdAqGR36aqtFJ7xTbmGXak98ZzXw10U9sA+QtkzMjc49PENIxihdD6cldX7Ist/PbE5k9bPFPkRj8RkmqabueHy0v9I8c8ZuEfW+2Fp6uoiRhg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750179458; c=relaxed/simple; bh=EkOzSUwlwr9JzNuG9Fq4X2zQwV2DOS5bRnGiCNwNEZ8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=o5XjIwPYKppZ/6XX18BRgOTJTl8dgPLemoJ7+fDfbAR59i9c45zwldE5q4G54HgAO+UzWb/vOo3Eun2A/yl1ZruYA0aI235gM5xAuGjwMad6Uy0+Lr2KRtOJnHi9H+L8Tz72vnkKjJ5l6uNRicE10rRBLv3iyChRVYOPUmGnrCY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=FY0yhH4c; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="FY0yhH4c" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E5F2AC4CEE3; Tue, 17 Jun 2025 16:57:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1750179458; bh=EkOzSUwlwr9JzNuG9Fq4X2zQwV2DOS5bRnGiCNwNEZ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FY0yhH4cNwgSnGSHzOFX+qYyTdnVn9YepE8yOIyjWkp/4TjhaqVjhdxyv8PDorPP+ icw/EeacmSHg+4nNA0WQcg0FZiFjdUun9FgR6JwV6GtiobeKI6sNUS836ODCqeZDe/ 4ar5Q8hzcwqvY/TiBWL4QURfR/ZeivY8n34GZHo4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Dave Penkler Subject: [PATCH 6.15 753/780] usb: usbtmc: Fix read_stb function and get_stb ioctl Date: Tue, 17 Jun 2025 17:27:41 +0200 Message-ID: <20250617152522.175618530@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250617152451.485330293@linuxfoundation.org> References: <20250617152451.485330293@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dave Penkler commit acb3dac2805d3342ded7dbbd164add32bbfdf21c upstream. The usbtmc488_ioctl_read_stb function relied on a positive return from usbtmc_get_stb to reset the srq condition in the driver. The USBTMC_IOCTL_GET_STB case tested for a positive return to return the stb to the user. Commit: ("usb: usbtmc: Fix erroneous get_stb ioctl error returns") changed the return value of usbtmc_get_stb to 0 on success instead of returning the value of usb_control_msg which is positive in the normal case. This change caused the function usbtmc488_ioctl_read_stb and the USBTMC_IOCTL_GET_STB ioctl to no longer function correctly. Change the test in usbtmc488_ioctl_read_stb to test for failure first and return the failure code immediately. Change the test for the USBTMC_IOCTL_GET_STB ioctl to test for 0 instead of a positive value. Fixes: cac01bd178d6 ("usb: usbtmc: Fix erroneous get_stb ioctl error returns") Cc: stable@vger.kernel.org Signed-off-by: Dave Penkler Link: https://lore.kernel.org/r/20250521121656.18174-3-dpenkler@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/class/usbtmc.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) --- a/drivers/usb/class/usbtmc.c +++ b/drivers/usb/class/usbtmc.c @@ -565,14 +565,15 @@ static int usbtmc488_ioctl_read_stb(stru rv = usbtmc_get_stb(file_data, &stb); - if (rv > 0) { - srq_asserted = atomic_xchg(&file_data->srq_asserted, - srq_asserted); - if (srq_asserted) - stb |= 0x40; /* Set RQS bit */ + if (rv < 0) + return rv; + + srq_asserted = atomic_xchg(&file_data->srq_asserted, srq_asserted); + if (srq_asserted) + stb |= 0x40; /* Set RQS bit */ + + rv = put_user(stb, (__u8 __user *)arg); - rv = put_user(stb, (__u8 __user *)arg); - } return rv; } @@ -2201,7 +2202,7 @@ static long usbtmc_ioctl(struct file *fi case USBTMC_IOCTL_GET_STB: retval = usbtmc_get_stb(file_data, &tmp_byte); - if (retval > 0) + if (!retval) retval = put_user(tmp_byte, (__u8 __user *)arg); break;