 scsi: ufs: core: Fix handling of lrbp-&gt;cmd · gregkh/linux@f3ee24a · 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 f3ee24a 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; Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt; 1 parent bf37fe5 commit f3ee24a Copy full SHA for f3ee24a 1 file changed + 1 - 6 Lines changed: 1 addition &amp; 6 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 - 6 Lines changed: 1 addition &amp; 6 deletions Original file line number Diff line number Diff line change @@ -2917,7 +2917,6 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) 2917 2917 ( hba -&gt; clk_gating . state != CLKS_ON )); 2918 2918 2919 2919 lrbp = &amp; hba -&gt; lrb [ tag ]; 2920 - WARN_ON ( lrbp -&gt; cmd ); 2921 2920 lrbp -&gt; cmd = cmd ; 2922 2921 lrbp -&gt; task_tag = tag ; 2923 2922 lrbp -&gt; lun = ufshcd_scsi_to_upiu_lun ( cmd -&gt; device -&gt; lun ); @@ -2933,7 +2932,6 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) 2933 2932 2934 2933 err = ufshcd_map_sg ( hba , lrbp ); 2935 2934 if ( err ) { 2936 - lrbp -&gt; cmd = NULL ; 2937 2935 ufshcd_release ( hba ); 2938 2936 goto out ; 2939 2937 } @@ -3152,7 +3150,7 @@ static int ufshcd_exec_dev_cmd(struct ufs_hba *hba, 3152 3150 down_read ( &amp; hba -&gt; clk_scaling_lock ); 3153 3151 3154 3152 lrbp = &amp; hba -&gt; lrb [ tag ]; 3155 - WARN_ON ( lrbp -&gt; cmd ) ; 3153 + lrbp -&gt; cmd = NULL ; 3156 3154 err = ufshcd_compose_dev_cmd ( hba , lrbp , cmd_type , tag ); 3157 3155 if ( unlikely ( err )) 3158 3156 goto out ; @@ -5391,7 +5389,6 @@ static void ufshcd_release_scsi_cmd(struct ufs_hba *hba, 5391 5389 struct scsi_cmnd * cmd = lrbp -&gt; cmd ; 5392 5390 5393 5391 scsi_dma_unmap ( cmd ); 5394 - lrbp -&gt; cmd = NULL ; /* Mark the command as completed. */ 5395 5392 ufshcd_release ( hba ); 5396 5393 ufshcd_clk_scaling_update_busy ( hba ); 5397 5394 } @@ -7006,7 +7003,6 @@ static int ufshcd_issue_devman_upiu_cmd(struct ufs_hba *hba, 7006 7003 down_read ( &amp; hba -&gt; clk_scaling_lock ); 7007 7004 7008 7005 lrbp = &amp; hba -&gt; lrb [ tag ]; 7009 - WARN_ON ( lrbp -&gt; cmd ); 7010 7006 lrbp -&gt; cmd = NULL ; 7011 7007 lrbp -&gt; task_tag = tag ; 7012 7008 lrbp -&gt; lun = 0 ; @@ -7178,7 +7174,6 @@ int ufshcd_advanced_rpmb_req_handler(struct ufs_hba *hba, struct utp_upiu_req *r 7178 7174 down_read ( &amp; hba -&gt; clk_scaling_lock ); 7179 7175 7180 7176 lrbp = &amp; hba -&gt; lrb [ tag ]; 7181 - WARN_ON ( lrbp -&gt; cmd ); 7182 7177 lrbp -&gt; cmd = NULL ; 7183 7178 lrbp -&gt; task_tag = tag ; 7184 7179 lrbp -&gt; lun = UFS_UPIU_RPMB_WLUN ; 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. 