 scsi: ufs: core: Fix handling of lrbp-&gt;cmd · gregkh/linux@b6d76d6 · GitHub Skip to content Navigation Menu Toggle navigation Sign in Appearance settings Platform AI CODE CREATION GitHub Copilot Write better code with AI GitHub Spark Build and deploy intelligent apps GitHub Models Manage and compare prompts MCP Registry New Integrate external tools DEVELOPER WORKFLOWS Actions Automate any workflow Codespaces Instant dev environments Issues Plan and track work Code Review Manage code changes APPLICATION SECURITY GitHub Advanced Security Find and fix vulnerabilities Code security Secure your code as you build Secret protection  EXPLORE Why GitHub Documentation Blog Changelog Marketplace View all features Solutions BY COMPANY SIZE Enterprises Small and medium teams Startups Nonprofits BY USE CASE App Modernization DevSecOps DevOps CI/CD View all use cases BY INDUSTRY Healthcare Financial services Manufacturing Government View all industries View all solutions Resources EXPLORE BY TOPIC AI Software Development DevOps Security View all topics EXPLORE BY TYPE Customer stories Events &amp; webinars Ebooks &amp; reports Business insights GitHub Skills SUPPORT &amp; SERVICES Documentation Customer support Community forum Trust center Partners View all resources Open Source COMMUNITY GitHub Sponsors Fund open source developers PROGRAMS Security Lab Maintainer Community Accelerator GitHub Stars Archive Program REPOSITORIES Topics Trending Collections Enterprise ENTERPRISE SOLUTIONS Enterprise platform AI-powered developer platform AVAILABLE ADD-ONS GitHub Advanced Security Enterprise-grade security features Copilot for Business Enterprise-grade AI features Premium Support Enterprise-grade 24/7 support Pricing Search or jump to... Search code, repositories, users, issues, pull requests... --> Search Clear Search syntax tips Provide feedback --> We read every piece of feedback, and take your input very seriously.  Cancel Submit feedback Saved searches Use saved searches to filter your results more quickly --> Name Query To see all available qualifiers, see our documentation . Cancel Create saved search Sign in Sign up Appearance settings Resetting focus You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }} gregkh / linux Public Notifications You must be signed in to change notification settings Fork 686 Star 644 Code Actions Security and quality 0 Insights Additional navigation options Code Actions Security and quality Insights Commit b6d76d6 Browse files Browse files bvanassche authored and gregkh committed scsi: ufs: core: Fix handling of lrbp-&gt;cmd [ Upstream commit 549e91a ] ufshcd_queuecommand() may be called two times in a row for a SCSI command before it is completed. Hence make the following changes: - In the functions that submit a command, do not check the old value of lrbp-&gt;cmd nor clear lrbp-&gt;cmd in error paths. - In ufshcd_release_scsi_cmd(), do not clear lrbp-&gt;cmd. See also scsi_send_eh_cmnd(). This commit prevents that the following appears if a command times out: WARNING: at drivers/ufs/core/ufshcd.c:2965 ufshcd_queuecommand+0x6f8/0x9a8 Call trace: ufshcd_queuecommand+0x6f8/0x9a8 scsi_send_eh_cmnd+0x2c0/0x960 scsi_eh_test_devices+0x100/0x314 scsi_eh_ready_devs+0xd90/0x114c scsi_error_handler+0x2b4/0xb70 kthread+0x16c/0x1e0 Fixes: 5a0b0cb ("[SCSI] ufs: Add support for sending NOP OUT UPIU") Signed-off-by: Bart Van Assche &lt;bvanassche@acm.org&gt; Link: https://lore.kernel.org/r/20230524203659.1394307-3-bvanassche@acm.org Acked-by: Adrian Hunter &lt;adrian.hunter@intel.com&gt; Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt; [ Removed the change in ufshcd_advanced_rpmb_req_handler() due to missing commit:6ff265fc5ef6("scsi: ufs: core: bsg: Add advanced RPMB support in ufs_bsg") ] Signed-off-by: Rajani Kantha &lt;681739313@139.com&gt; Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt; 1 parent cfa7458 commit b6d76d6 Copy full SHA for b6d76d6 1 file changed + 1 - 5 Lines changed: 1 addition &amp; 5 deletions File tree Expand file tree Collapse file tree Open diff view settings Filter options drivers/ufs/core ufshcd.c Expand file tree Collapse file tree Open diff view settings Collapse file ‎ drivers/ufs/core/ufshcd.c ‎ Copy file name to clipboard Expand all lines: drivers/ufs/core/ufshcd.c + 1 - 5 Lines changed: 1 addition &amp; 5 deletions Original file line number Diff line number Diff line change @@ -2821,7 +2821,6 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) 2821 2821 ( hba -&gt; clk_gating . state != CLKS_ON )); 2822 2822 2823 2823 lrbp = &amp; hba -&gt; lrb [ tag ]; 2824 - WARN_ON ( lrbp -&gt; cmd ); 2825 2824 lrbp -&gt; cmd = cmd ; 2826 2825 lrbp -&gt; task_tag = tag ; 2827 2826 lrbp -&gt; lun = ufshcd_scsi_to_upiu_lun ( cmd -&gt; device -&gt; lun ); @@ -2837,7 +2836,6 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) 2837 2836 2838 2837 err = ufshcd_map_sg ( hba , lrbp ); 2839 2838 if ( err ) { 2840 - lrbp -&gt; cmd = NULL ; 2841 2839 ufshcd_release ( hba ); 2842 2840 goto out ; 2843 2841 } @@ -3047,7 +3045,7 @@ static int ufshcd_exec_dev_cmd(struct ufs_hba *hba, 3047 3045 down_read ( &amp; hba -&gt; clk_scaling_lock ); 3048 3046 3049 3047 lrbp = &amp; hba -&gt; lrb [ tag ]; 3050 - WARN_ON ( lrbp -&gt; cmd ) ; 3048 + lrbp -&gt; cmd = NULL ; 3051 3049 err = ufshcd_compose_dev_cmd ( hba , lrbp , cmd_type , tag ); 3052 3050 if ( unlikely ( err )) 3053 3051 goto out ; @@ -5357,7 +5355,6 @@ static void ufshcd_release_scsi_cmd(struct ufs_hba *hba, 5357 5355 struct scsi_cmnd * cmd = lrbp -&gt; cmd ; 5358 5356 5359 5357 scsi_dma_unmap ( cmd ); 5360 - lrbp -&gt; cmd = NULL ; /* Mark the command as completed. */ 5361 5358 ufshcd_release ( hba ); 5362 5359 ufshcd_clk_scaling_update_busy ( hba ); 5363 5360 } @@ -6936,7 +6933,6 @@ static int ufshcd_issue_devman_upiu_cmd(struct ufs_hba *hba, 6936 6933 down_read ( &amp; hba -&gt; clk_scaling_lock ); 6937 6934 6938 6935 lrbp = &amp; hba -&gt; lrb [ tag ]; 6939 - WARN_ON ( lrbp -&gt; cmd ); 6940 6936 lrbp -&gt; cmd = NULL ; 6941 6937 lrbp -&gt; task_tag = tag ; 6942 6938 lrbp -&gt; lun = 0 ; 0 commit comments Comments 0 ( 0 ) Footer &copy; 2026 GitHub,&nbsp;Inc. Footer navigation Terms Privacy Security Status Community Docs Contact Manage cookies Do not share my personal information You can’t perform that action at this time. 