 scsi: ufs: core: Fix handling of lrbp-&gt;cmd · gregkh/linux@549e91a · 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 549e91a Browse files Browse files bvanassche authored and martinkpetersen committed scsi: ufs: core: Fix handling of lrbp-&gt;cmd 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; 1 parent fe8637f commit 549e91a Copy full SHA for 549e91a 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 @@ -2945,7 +2945,6 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) 2945 2945 ( hba -&gt; clk_gating . state != CLKS_ON )); 2946 2946 2947 2947 lrbp = &amp; hba -&gt; lrb [ tag ]; 2948 - WARN_ON ( lrbp -&gt; cmd ); 2949 2948 lrbp -&gt; cmd = cmd ; 2950 2949 lrbp -&gt; task_tag = tag ; 2951 2950 lrbp -&gt; lun = ufshcd_scsi_to_upiu_lun ( cmd -&gt; device -&gt; lun ); @@ -2961,7 +2960,6 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) 2961 2960 2962 2961 err = ufshcd_map_sg ( hba , lrbp ); 2963 2962 if ( err ) { 2964 - lrbp -&gt; cmd = NULL ; 2965 2963 ufshcd_release ( hba ); 2966 2964 goto out ; 2967 2965 } @@ -3180,7 +3178,7 @@ static int ufshcd_exec_dev_cmd(struct ufs_hba *hba, 3180 3178 down_read ( &amp; hba -&gt; clk_scaling_lock ); 3181 3179 3182 3180 lrbp = &amp; hba -&gt; lrb [ tag ]; 3183 - WARN_ON ( lrbp -&gt; cmd ) ; 3181 + lrbp -&gt; cmd = NULL ; 3184 3182 err = ufshcd_compose_dev_cmd ( hba , lrbp , cmd_type , tag ); 3185 3183 if ( unlikely ( err )) 3186 3184 goto out ; @@ -5422,7 +5420,6 @@ static void ufshcd_release_scsi_cmd(struct ufs_hba *hba, 5422 5420 struct scsi_cmnd * cmd = lrbp -&gt; cmd ; 5423 5421 5424 5422 scsi_dma_unmap ( cmd ); 5425 - lrbp -&gt; cmd = NULL ; /* Mark the command as completed. */ 5426 5423 ufshcd_release ( hba ); 5427 5424 ufshcd_clk_scaling_update_busy ( hba ); 5428 5425 } @@ -7037,7 +7034,6 @@ static int ufshcd_issue_devman_upiu_cmd(struct ufs_hba *hba, 7037 7034 down_read ( &amp; hba -&gt; clk_scaling_lock ); 7038 7035 7039 7036 lrbp = &amp; hba -&gt; lrb [ tag ]; 7040 - WARN_ON ( lrbp -&gt; cmd ); 7041 7037 lrbp -&gt; cmd = NULL ; 7042 7038 lrbp -&gt; task_tag = tag ; 7043 7039 lrbp -&gt; lun = 0 ; @@ -7209,7 +7205,6 @@ int ufshcd_advanced_rpmb_req_handler(struct ufs_hba *hba, struct utp_upiu_req *r 7209 7205 down_read ( &amp; hba -&gt; clk_scaling_lock ); 7210 7206 7211 7207 lrbp = &amp; hba -&gt; lrb [ tag ]; 7212 - WARN_ON ( lrbp -&gt; cmd ); 7213 7208 lrbp -&gt; cmd = NULL ; 7214 7209 lrbp -&gt; task_tag = tag ; 7215 7210 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. 