Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp339744lqs; Thu, 13 Jun 2024 11:28:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVkv4CRWrIMayL8uMI2qnNdddUnbiY0skUp0O1CohU2aOA06rJoos1QnQx1HuUKbZk56j5jSU1MdWIaCvmVj9N0yXF0ruaQuIG8yRlw5w== X-Google-Smtp-Source: AGHT+IHBG/uPNKTT35TYcHZjVGuhmy+AkDWbJtFxCRMbc8fLtfBZoliNM4y+KeXD+x3iewPJUOQG X-Received: by 2002:a17:906:528a:b0:a6f:501c:5da8 with SMTP id a640c23a62f3a-a6f60d27e07mr45789666b.22.1718303300387; Thu, 13 Jun 2024 11:28:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718303300; cv=pass; d=google.com; s=arc-20160816; b=BpO567Hz8C0dQXsX8ZFYgHgHB9ULmxVYheZwLDLYN/dyj/mQgOgyRw3DSS719Amu59 9zMId/o3rUmBp2tgag4qVKmB1CgmqVUEmJ1cQnet2wpbctM64hL40GusBK1mbqT2LjIa ud2VNFgtWkAkgySijGAtyP/zDNYVJAgUBX/aHfauU4dY5KC6B4LzeMXQN0ysBojMbsLy 5yFtjzlnAPPg6DGMFkU5BnsLqddDV4YunlY5mOH7l9ASR9+QcPreLSraUXxsaMqjSdF7 i1PpcsnB+P3QbMlZsELudmF3xXNmCfEQwBSudXRplbXW8wtKsH8XqkCrfnG12mn4Vjxa y1KA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=Pt7JMdv2zQuXXKN4eq/m/SVF3iNPHye0V9QpcQS+Yf0=; fh=dZh4PazuFCdKl8+OOIXjvYIdeYUBZLdiSFc8IoDi+Jk=; b=BbHMG72TzjAy5B3+jBu4Q9D50vU9rG8Zihonvq3f73HW0lJq9uDQVsgfvNV5eim5oE V1vMkqybcgTJeSR+EskJBqhThFySIMAh3lown6XnT9q+AgYquixtkr22rP5vDRrdwUKo 58hMrQEIkGZCRE9IuChAdCKXrbp3jyjI/HcXn/o4a9JBVfNbzxlORy2Ldfipg3HoO1YH /1niVk7ScL4BfLniX5d8z3Mf24He7nJkRWW0E4vxGeJ1f1RicoWOKuMg0bXxQm5zpaSd 42JJkiDr6cJF4vNT1ZW54D6loOU6SAk11k3/OWViXT18vcaV6C/ffI5Sh7p9CKsU6IHF Ux8A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Z7EE0vuV; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-213826-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213826-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a6f56dd66ffsi90188766b.362.2024.06.13.11.28.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 11:28:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-213826-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Z7EE0vuV; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-213826-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213826-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 1B89D1F2212B for ; Thu, 13 Jun 2024 18:28:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D547814B082; Thu, 13 Jun 2024 18:28:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Z7EE0vuV" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 AE1E414B061 for ; Thu, 13 Jun 2024 18:28:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718303290; cv=none; b=cNKOcl+CuTNLyChzqImlVwRw2OJzIfPgxkeOv2Z1MJHBLuoayMoPMWbU4baEZNfTOhhKAV3+sOQ/kCmgGSh/yYlv0eS2xO/9W1By8mnbvEYqOqGBXwVbAg+CgiH8R6mQTlP8tpBTjFt7O6vbpzayjpYgoIs/CEGmparAeQjA2zs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718303290; c=relaxed/simple; bh=4Pm7lRVeDxAxTTAE1RjwSM52yXCD4XEqdMVtN4NZ2wc=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=BzdI8pvVmlK6rzKS7JTknGFkM+O+dN4g3qO0bhMe7681BYg3Z9l9U7afYHBYrNF0y4gzIVCjVWM52oGJr5E3dFzahh/OAIJKJR8mqjTm6X3FZ1akYMnDQWZmsMgw4+HbnjJPQynK1DtulIDKSsqRc1fFtBbFWdVwqh7xpZRZzKE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Z7EE0vuV; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718303287; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=Pt7JMdv2zQuXXKN4eq/m/SVF3iNPHye0V9QpcQS+Yf0=; b=Z7EE0vuVIb8PrR/WHTekExUYSBiZjH92nvKaHfUxZ0vMHPQN/Rm9aEOXNxum2g6rmjy5Wr q+MLw/XEyfz0fUcS1LE+8mXoTjySB3lXF61yKslpxaaH031hvrH+9bX7MdPqVe0IAk4KMQ dymP3sDqZ0tDK9varRXheLQwmDo68lQ= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-317-a9ivuM1jPDeAsFZDy-CvfQ-1; Thu, 13 Jun 2024 14:28:04 -0400 X-MC-Unique: a9ivuM1jPDeAsFZDy-CvfQ-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1D69A1956095; Thu, 13 Jun 2024 18:28:02 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.16.90]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A192B1956058; Thu, 13 Jun 2024 18:27:58 +0000 (UTC) From: Joel Slebodnick To: linux-scsi@vger.kernel.org Cc: linux-kernel@vger.kernel.org, alim.akhtar@samsung.com, avri.altman@wdc.com, bvanassche@acm.org, James.Bottomley@HansenPartnership.com, martin.petersen@oracle.com, peter.wang@mediatek.com, manivannan.sadhasivam@linaro.org, ahalaney@redhat.com, beanhuo@micron.com, Joel Slebodnick Subject: [PATCH] scsi: ufs: core: Free memory allocated for model before reinit Date: Thu, 13 Jun 2024 14:27:28 -0400 Message-Id: <20240613182728.2521951-1-jslebodn@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Under the conditions that a device is to be reinitialized within ufshcd_probe_hba, the device must first be fully reset. Resetting the device should include freeing U8 model (member of dev_info) but does not, and this causes a memory leak. ufs_put_device_desc is responsible for freeing model. unreferenced object 0xffff3f63008bee60 (size 32): comm "kworker/u33:1", pid 60, jiffies 4294892642 hex dump (first 32 bytes): 54 48 47 4a 46 47 54 30 54 32 35 42 41 5a 5a 41 THGJFGT0T25BAZZA 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace (crc ed7ff1a9): [] kmemleak_alloc+0x34/0x40 [] __kmalloc_noprof+0x1e4/0x2fc [] ufshcd_read_string_desc+0x94/0x190 [] ufshcd_device_init+0x480/0xdf8 [] ufshcd_probe_hba+0x3c/0x404 [] ufshcd_async_scan+0x40/0x370 [] async_run_entry_fn+0x34/0xe0 [] process_one_work+0x154/0x298 [] worker_thread+0x2f8/0x408 [] kthread+0x114/0x118 [] ret_from_fork+0x10/0x20 Signed-off-by: Joel Slebodnick --- drivers/ufs/core/ufshcd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 0cf07194bbe8..a0407b9213ca 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -8787,6 +8787,7 @@ static int ufshcd_probe_hba(struct ufs_hba *hba, bool init_dev_params) (hba->quirks & UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCH)) { /* Reset the device and controller before doing reinit */ ufshcd_device_reset(hba); + ufs_put_device_desc(hba); ufshcd_hba_stop(hba); ufshcd_vops_reinit_notify(hba); ret = ufshcd_hba_enable(hba); -- 2.40.1