<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/drivers/usb/gadget/function/f_tcm.c, branch linux-5.10.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.10.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.10.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2025-07-17T16:27:37Z</updated>
<entry>
<title>usb: potential integer overflow in usbg_make_tpg()</title>
<updated>2025-07-17T16:27:37Z</updated>
<author>
<name>Chen Yufeng</name>
</author>
<published>2025-04-15T06:58:57Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=603a83e5fee38a950bfcfb2f36449311fa00a474'/>
<id>urn:sha1:603a83e5fee38a950bfcfb2f36449311fa00a474</id>
<content type='text'>
[ Upstream commit 153874010354d050f62f8ae25cbb960c17633dc5 ]

The variable tpgt in usbg_make_tpg() is defined as unsigned long and is
assigned to tpgt-&gt;tport_tpgt, which is defined as u16. This may cause an
integer overflow when tpgt is greater than USHRT_MAX (65535). I
haven't tried to trigger it myself, but it is possible to trigger it
by calling usbg_make_tpg() with a large value for tpgt.

I modified the type of tpgt to match tpgt-&gt;tport_tpgt and adjusted the
relevant code accordingly.

This patch is similar to commit 59c816c1f24d ("vhost/scsi: potential
memory corruption").

Signed-off-by: Chen Yufeng &lt;chenyufeng@iie.ac.cn&gt;
Link: https://lore.kernel.org/r/20250415065857.1619-1-chenyufeng@iie.ac.cn
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>usb: gadget: f_tcm: Don't prepare BOT write request twice</title>
<updated>2025-03-13T11:47:09Z</updated>
<author>
<name>Thinh Nguyen</name>
</author>
<published>2024-12-11T00:32:07Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=b6358f4c362631879682f909acf8fd0047ef399d'/>
<id>urn:sha1:b6358f4c362631879682f909acf8fd0047ef399d</id>
<content type='text'>
commit 94d9bf671ae314cacc2d7bf96bd233b4abc7cede upstream.

The duplicate kmalloc here is causing memory leak. The request
preparation in bot_send_write_request is also done in
usbg_prepare_w_request. Remove the duplicate work.

Fixes: c52661d60f63 ("usb-gadget: Initial merge of target module for UASP + BOT")
Cc: stable@vger.kernel.org
Signed-off-by: Thinh Nguyen &lt;Thinh.Nguyen@synopsys.com&gt;
Link: https://lore.kernel.org/r/f4f26c3d586cde0d46f8c3bcb4e8ae32311b650d.1733876548.git.Thinh.Nguyen@synopsys.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>usb: gadget: f_tcm: ep_autoconfig with fullspeed endpoint</title>
<updated>2025-03-13T11:47:09Z</updated>
<author>
<name>Thinh Nguyen</name>
</author>
<published>2024-12-11T00:32:01Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=3fba3523cdfd9f963c0adc0e17bf9003ae4230ec'/>
<id>urn:sha1:3fba3523cdfd9f963c0adc0e17bf9003ae4230ec</id>
<content type='text'>
commit 25224c1f07d31c261d04dfbc705a7a0f314a825d upstream.

Match usb endpoint using fullspeed endpoint descriptor to make sure the
wMaxPacketSize for fullspeed descriptors is automatically configured.

Fixes: c52661d60f63 ("usb-gadget: Initial merge of target module for UASP + BOT")
Cc: stable@vger.kernel.org
Signed-off-by: Thinh Nguyen &lt;Thinh.Nguyen@synopsys.com&gt;
Link: https://lore.kernel.org/r/e4507bc824aed6e7c7f5a718392ab6a7c1480a7f.1733876548.git.Thinh.Nguyen@synopsys.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>usb: gadget: f_tcm: Decrement command ref count on cleanup</title>
<updated>2025-03-13T11:47:08Z</updated>
<author>
<name>Thinh Nguyen</name>
</author>
<published>2024-12-11T00:31:48Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=b77748d7ff5e14af321527451dcfba78a47c9d6b'/>
<id>urn:sha1:b77748d7ff5e14af321527451dcfba78a47c9d6b</id>
<content type='text'>
commit 3b2a52e88ab0c9469eaadd4d4c8f57d072477820 upstream.

We submitted the command with TARGET_SCF_ACK_KREF, which requires
acknowledgment of command completion. If the command fails, make sure to
decrement the ref count.

Fixes: cff834c16d23 ("usb-gadget/tcm: Convert to TARGET_SCF_ACK_KREF I/O krefs")
Cc: stable@vger.kernel.org
Signed-off-by: Thinh Nguyen &lt;Thinh.Nguyen@synopsys.com&gt;
Link: https://lore.kernel.org/r/3c667b4d9c8b0b580346a69ff53616b6a74cfea2.1733876548.git.Thinh.Nguyen@synopsys.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>usb: gadget: f_tcm: Translate error to sense</title>
<updated>2025-03-13T11:47:08Z</updated>
<author>
<name>Thinh Nguyen</name>
</author>
<published>2024-12-11T00:31:43Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=b8b131c6a95f06e2d27feee829082b6e98c07d25'/>
<id>urn:sha1:b8b131c6a95f06e2d27feee829082b6e98c07d25</id>
<content type='text'>
commit 98fa00fd3ae43b857b4976984a135483d89d9281 upstream.

When respond with check_condition error status, clear from_transport
input so the target layer can translate the sense reason reported by
f_tcm.

Fixes: c52661d60f63 ("usb-gadget: Initial merge of target module for UASP + BOT")
Cc: stable@vger.kernel.org
Signed-off-by: Thinh Nguyen &lt;Thinh.Nguyen@synopsys.com&gt;
Link: https://lore.kernel.org/r/b2a5577efe7abd0af0051229622cf7d3be5cdcd0.1733876548.git.Thinh.Nguyen@synopsys.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>usb: gadget: f_tcm: Don't free command immediately</title>
<updated>2025-03-13T11:47:00Z</updated>
<author>
<name>Thinh Nguyen</name>
</author>
<published>2024-12-11T00:31:36Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=38229c35a6d7875697dfb293356407330cfcd23e'/>
<id>urn:sha1:38229c35a6d7875697dfb293356407330cfcd23e</id>
<content type='text'>
commit c225d006a31949d673e646d585d9569bc28feeb9 upstream.

Don't prematurely free the command. Wait for the status completion of
the sense status. It can be freed then. Otherwise we will double-free
the command.

Fixes: cff834c16d23 ("usb-gadget/tcm: Convert to TARGET_SCF_ACK_KREF I/O krefs")
Cc: stable@vger.kernel.org
Signed-off-by: Thinh Nguyen &lt;Thinh.Nguyen@synopsys.com&gt;
Link: https://lore.kernel.org/r/ae919ac431f16275e05ec819bdffb3ac5f44cbe1.1733876548.git.Thinh.Nguyen@synopsys.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>usb: gadget: f_tcm: Fix Get/SetInterface return value</title>
<updated>2025-03-13T11:46:59Z</updated>
<author>
<name>Thinh Nguyen</name>
</author>
<published>2024-12-11T00:31:55Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=3f60d759eb99d562eb90aad8d5d87c6521ed87f9'/>
<id>urn:sha1:3f60d759eb99d562eb90aad8d5d87c6521ed87f9</id>
<content type='text'>
commit 3b997089903b909684114aca6f79d683e5c64a0e upstream.

Check to make sure that the GetInterface and SetInterface are for valid
interface. Return proper alternate setting number on GetInterface.

Fixes: 0b8b1a1fede0 ("usb: gadget: f_tcm: Provide support to get alternate setting in tcm function")
Cc: stable@vger.kernel.org
Signed-off-by: Thinh Nguyen &lt;Thinh.Nguyen@synopsys.com&gt;
Link: https://lore.kernel.org/r/ffd91b4640945ea4d3b4f4091cf1abbdbd9cf4fc.1733876548.git.Thinh.Nguyen@synopsys.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>usb: fix various gadgets null ptr deref on 10gbps cabling.</title>
<updated>2021-06-16T10:01:42Z</updated>
<author>
<name>Maciej Żenczykowski</name>
</author>
<published>2021-06-08T04:41:41Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=4b289a0f3033f465b4fd51ba995251a7867a2aa2'/>
<id>urn:sha1:4b289a0f3033f465b4fd51ba995251a7867a2aa2</id>
<content type='text'>
commit 90c4d05780d47e14a50e11a7f17373104cd47d25 upstream.

This avoids a null pointer dereference in
f_{ecm,eem,hid,loopback,printer,rndis,serial,sourcesink,subset,tcm}
by simply reusing the 5gbps config for 10gbps.

Fixes: eaef50c76057 ("usb: gadget: Update usb_assign_descriptors for SuperSpeedPlus")
Cc: Christophe JAILLET &lt;christophe.jaillet@wanadoo.fr&gt;
Cc: Felipe Balbi &lt;balbi@kernel.org&gt;
Cc: Gustavo A. R. Silva &lt;gustavoars@kernel.org&gt;
Cc: Lorenzo Colitti &lt;lorenzo@google.com&gt;
Cc: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Cc: Michael R Sweet &lt;msweet@msweet.org&gt;
Cc: Mike Christie &lt;michael.christie@oracle.com&gt;
Cc: Pawel Laszczak &lt;pawell@cadence.com&gt;
Cc: Peter Chen &lt;peter.chen@nxp.com&gt;
Cc: Sudhakar Panneerselvam &lt;sudhakar.panneerselvam@oracle.com&gt;
Cc: Wei Ming Chen &lt;jj251510319013@gmail.com&gt;
Cc: Will McVicker &lt;willmcvicker@google.com&gt;
Cc: Zqiang &lt;qiang.zhang@windriver.com&gt;
Reviewed-By: Lorenzo Colitti &lt;lorenzo@google.com&gt;
Cc: stable &lt;stable@vger.kernel.org&gt;
Signed-off-by: Maciej Żenczykowski &lt;maze@google.com&gt;
Link: https://lore.kernel.org/r/20210608044141.3898496-1-zenczykowski@gmail.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>usb: gadget: config_ep_by_speed_and_alt instead of config_ep_by_speed</title>
<updated>2020-10-02T06:57:40Z</updated>
<author>
<name>Pawel Laszczak</name>
</author>
<published>2020-09-18T08:30:35Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=864bc7e7297fe9282a7e17f01806029eb1d675c1'/>
<id>urn:sha1:864bc7e7297fe9282a7e17f01806029eb1d675c1</id>
<content type='text'>
This patch replace config_ep_by_speed with config_ep_by_speed_and_alt.
This change allows to select proper usb_ss_ep_comp_descriptor for each
stream capable endpoints.

f_tcm function for SS use array of headers for both BOT/UAS alternate
setting:

static struct usb_descriptor_header *uasp_ss_function_desc[] = {
        (struct usb_descriptor_header *) &amp;bot_intf_desc,
        (struct usb_descriptor_header *) &amp;uasp_ss_bi_desc,
        (struct usb_descriptor_header *) &amp;bot_bi_ep_comp_desc,
        (struct usb_descriptor_header *) &amp;uasp_ss_bo_desc,
        (struct usb_descriptor_header *) &amp;bot_bo_ep_comp_desc,

        (struct usb_descriptor_header *) &amp;uasp_intf_desc,
        (struct usb_descriptor_header *) &amp;uasp_ss_bi_desc,
        (struct usb_descriptor_header *) &amp;uasp_bi_ep_comp_desc,
        (struct usb_descriptor_header *) &amp;uasp_bi_pipe_desc,
        (struct usb_descriptor_header *) &amp;uasp_ss_bo_desc,
        (struct usb_descriptor_header *) &amp;uasp_bo_ep_comp_desc,
        (struct usb_descriptor_header *) &amp;uasp_bo_pipe_desc,
        (struct usb_descriptor_header *) &amp;uasp_ss_status_desc,
        (struct usb_descriptor_header *) &amp;uasp_status_in_ep_comp_desc,
        (struct usb_descriptor_header *) &amp;uasp_status_pipe_desc,
        (struct usb_descriptor_header *) &amp;uasp_ss_cmd_desc,
        (struct usb_descriptor_header *) &amp;uasp_cmd_comp_desc,
        (struct usb_descriptor_header *) &amp;uasp_cmd_pipe_desc,
        NULL,
};

The first 5 descriptors are associated with BOT alternate setting,
and others are associated with UAS.

During handling UAS alternate setting f_tcm driver invokes
config_ep_by_speed and this function sets incorrect companion endpoint
descriptor in usb_ep object.

Instead setting ep-&gt;comp_desc to uasp_bi_ep_comp_desc function in this
case set ep-&gt;comp_desc to bot_uasp_ss_bi_desc.

And in result it uses the descriptor from BOT alternate setting
instead UAS.

Finally, it causes that controller driver during enabling endpoints
detect that just enabled endpoint for bot.

Signed-off-by: Jayshri Pawar &lt;jpawar@cadence.com&gt;
Signed-off-by: Pawel Laszczak &lt;pawell@cadence.com&gt;
Reviewed-by: Peter Chen &lt;peter.chen@nxp.com&gt;
Signed-off-by: Felipe Balbi &lt;balbi@kernel.org&gt;
</content>
</entry>
<entry>
<title>usb: gadget: f_tcm: Fix some resource leaks in some error paths</title>
<updated>2020-08-17T10:35:22Z</updated>
<author>
<name>Christophe JAILLET</name>
</author>
<published>2020-08-14T05:55:01Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=07c8434150f4eb0b65cae288721c8af1080fde17'/>
<id>urn:sha1:07c8434150f4eb0b65cae288721c8af1080fde17</id>
<content type='text'>
If a memory allocation fails within a 'usb_ep_alloc_request()' call, the
already allocated memory must be released.

Fix a mix-up in the code and free the correct requests.

Fixes: c52661d60f63 ("usb-gadget: Initial merge of target module for UASP + BOT")
Signed-off-by: Christophe JAILLET &lt;christophe.jaillet@wanadoo.fr&gt;
Signed-off-by: Felipe Balbi &lt;balbi@kernel.org&gt;
</content>
</entry>
</feed>
