From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (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 484C743A80B for ; Tue, 11 Aug 2026 09:32:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786440724; cv=none; b=bqenpMsq0YUNat1a9RJjdF+si9C10/sz9jgjj9Ykx1Pl9bCVQlRscmPZEPczzc9vRMMrO9EujxfVYeRt9zt/6YoX/jcBsR+NMQjug9y9U/wf52BBHbdfs6EvPVPpQXjbuqHp7Ubn5IZTSsnATzI3/vv5DQBtLuSSnErSS36xWXM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786440724; c=relaxed/simple; bh=u91ReNtJhgOHizhOctS1mLFRoqetFf5wRo360YEBbww=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=iiECIXWJJiqRzgB9TYDBIZrSe093aNlBpEZgWXbpncdpDw1jn5tC7v9w+Gk32figTC5zCRWXrqJnolqVQcPl5TH5kQMqM/SU5VibN58r1bbMz4vgM67S4q/wvYuL0xHPGa5sxp6ldDcxQ6IMwvlyqtpZad2qIcWTJKYzucQlFPo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=T8HQUYFq; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=jSazOQFM; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="T8HQUYFq"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="jSazOQFM" Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 67B7QKD92937762 for ; Tue, 11 Aug 2026 09:32:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= aLvgNJF2m8GZrgcuRRob5EYPfrcy3+MhYzQhJ2G0Cco=; b=T8HQUYFqK4YE5JIo xgJGAcFL8L0FvQbqBkwfdjQNTE+zBJNQsDTmSGOfcHeC9ccH7/2VXM/YPN1T/1z2 7rUV9RrIkwhzmqZnO1UjbMq6+aKJcD6+PUCXrvt24a6F4I+hEwwDRykIZ4RXpQGD s8CKQZ0B/KuAVql3aY77FjEquSS04/lPmPbkRhaRvUKYM+0gCgNkkCyVK81sZJyr UkoiYe+veQVOYn0nq38J48rKI39UBhVnGskvJ3cYUB+FdKyoBv2vToF77lf4S1W0 0xe8hM/KK+yX9ABoF+YziWhyzuqQUgoaNteGl3fnJuDpavmck+tp+XeIVvykRmBY Cv24Sg== Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4fyjjv3df5-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 11 Aug 2026 09:32:02 +0000 (GMT) Received: by mail-pf1-f199.google.com with SMTP id d2e1a72fcca58-8488ac68185so7617437b3a.2 for ; Tue, 11 Aug 2026 02:32:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1786440721; x=1787045521; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=aLvgNJF2m8GZrgcuRRob5EYPfrcy3+MhYzQhJ2G0Cco=; b=jSazOQFMDL05xm9b3fLDi1iX1pxiLK1n5ysfeG3Q5vd8b8p5aTLoLqZFlaAgvzDcbX ugTCBDAzw818/p2LHtKOqSjEjBjf7IXZzS8/aO140LwjKdB/Dku7vbhLClsxfJma1by+ a68rWXtaurOnTxlb4y2y9X4STd/iiz/jqQrZoyeaOi4GkqUrapyb/MoVPW/LzLXPvyou 8UvDtKKCoaylbAowC8Bcg30j5H1n7Dv050V/ogeLxsuma4zyVjWIzBV/2x/5PXC3ESl4 fsKDHH1f5kJDamimmj87msRHyQGfmJyPxFyz8wB5H0NM3+ups43Y9gByPpi8CcmeIZmG ppVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786440721; x=1787045521; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=aLvgNJF2m8GZrgcuRRob5EYPfrcy3+MhYzQhJ2G0Cco=; b=AkvtZVI7X/pJJaGpOxV3Ffksy5tVYjP9j/dtJX1W1LYbLKFgRTog0VsG3AqQe8XfwP mJIJ8IzHeEocd57H/lZfAcK6iwxhRSFX916Km4FubUeUUpOdXCpVuQ6BYnFPRUOY65ZL 2hKKV91xyrpTDWdF4ZKwBvC/sXOPoCwwykRMH9cksilg2FbHX8W8IAKbV12rPMBRAp5h 5vPcZ0NAuzFP12OjF+2dc1FeW5cANo5PUW6u7k7tJ7qPGAGGDmln1AZ7VaPfn7lZU8JT +rdg9yuM/1zGTAXlCLa/9R6bO9zFZASCj3IrRgzqJhPWSTxFs6fBvSCRL4SVrWUIY1L4 qBsw== X-Forwarded-Encrypted: i=1; AHgh+Rpz/u/LbrwB2lDZVVSUi9ZelzbGrrGRQjdcvraTq3y/F0zMhXwfj5RMLXJOUrs27AVOKLFwGdvXhPm6GuA=@vger.kernel.org X-Gm-Message-State: AOJu0YwTwSXy9Q0lNcJ+/q23dfc84Rq1XyBGdHfqujnea/Z8p6/CJr8B KsJyW7rX0FiSSFrAxsOGKOY/vPgJKs50ftSijCjc1XRZJ0U/JiGc/ziyVSV2MFyStU+Hvq0xhn1 TC0gJpr8AzBvOBY/6Su3fwPrQMXPzJgYDBpD/Hj/GJ/5/l74BNfzMfAqyJlQ1VFWXwHw= X-Gm-Gg: AR+sD13ntjKki34zF0MhSXpUkl2dO1NrXTmZ41V2vlEBeiw7AJq4hFCKEoGOXcBb2KF DawnAdl0fdDdUnrbfTv8NhRgey+IRdluJD3fu3iBHbMpupJfLg0nVy6yktmQ5LGD0WVq96Xci4A RjfHqZjOzDv5lg9rgW8OACm1AYZcn0MasjlekEgpEe2J2UizUb/r2RGkrZwfr8amsgq5YpaTbKE dv+zHe3Ayj7kAa2W56ko4Gi4wZdRl0HDV+QuuDdqUoUQM+OLLim3016T8lMXc1CC/BiH/ANGq7L YWohzdP+9no7I3tJjZYfQ2rAXjoVmBLEa31xVhRDJxyB7E9GLn1lr4t/96XgpkOaDKWFPjV4qo+ 2E7JXLC9ZRYqdOagW4odHjwQTIalHfghTTA== X-Received: by 2002:a05:6a00:234a:b0:842:5da3:9b89 with SMTP id d2e1a72fcca58-84fa888ccacmr1609030b3a.38.1786440721059; Tue, 11 Aug 2026 02:32:01 -0700 (PDT) X-Received: by 2002:a05:6a00:234a:b0:842:5da3:9b89 with SMTP id d2e1a72fcca58-84fa888ccacmr1608980b3a.38.1786440720602; Tue, 11 Aug 2026 02:32:00 -0700 (PDT) Received: from [10.217.219.92] ([202.46.22.19]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-84fa9526485sm403122b3a.33.2026.08.11.02.31.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 11 Aug 2026 02:32:00 -0700 (PDT) Message-ID: Date: Tue, 11 Aug 2026 15:01:56 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] dmaengine: qcom: gpi: Fix channel cleanup in unwind path To: Aniket Randive , Vinod Koul , Frank Li Cc: linux-arm-msm@vger.kernel.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org References: <20260810-gpi_bug_fix-v2-1-60555394cbf9@oss.qualcomm.com> Content-Language: en-US From: Mukesh Savaliya In-Reply-To: <20260810-gpi_bug_fix-v2-1-60555394cbf9@oss.qualcomm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODExMDA3OCBTYWx0ZWRfX47INXvlRWZ/P TANJk/zwfc7ZhKixiCU5aZSi7/SX9tuQV0qDifQRn5oZ9KqXVm3CebEYWvws4oBJzVQsxGD6xja wYApBIENaD2/PBnVXC72nSo+9yxTXLa3D9ep3+g+HN8gQp2SgRrcRqsTc0EtaJlMq4weO3/4oF2 SY1OXdC6davHqTI4FjSPQyOE+CMKXiJV5o3UeE/CS5AFZhXHwRbweid2JCPEA4rWWHuPV8BTewa QmVFo30c5+v1AVQBZz2NYUvh2Li+wjHzXJsWfdbrSK5zKdnbXvrjH1zUIFHdXoWo4C6diMryjtM gAR1MUweiMuc0+Y6LIjRa+2En60g4281aHwm6z2ZTj2BnYlaA5mrt/Yp3ooElEWrQCivBMjrbhE G9OHHTA2ZAB99uUohPSsb4tXekmwaGFtGzF3L/sOycSVs6SxVCQtUACOC7+FPg3+HQItlT2NIDN Eh3LmuULNY2bH19Hs/w== X-Proofpoint-ORIG-GUID: jBUzYxdTDKoopMA9O5Lzp8c65_U6PIUs X-Authority-Analysis: v=2.4 cv=KLtqylFo c=1 sm=1 tr=0 ts=6a7aec12 cx=c_pps a=WW5sKcV1LcKqjgzy2JUPuA==:117 a=fChuTYTh2wq5r3m49p7fHw==:17 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=ZpdpYltYx_vBUK5n70dp:22 a=EUspDBNiAAAA:8 a=L926Rc6u3fOPukkFLXgA:9 a=QEXdDO2ut3YA:10 a=OpyuDcXvxspvyRM73sMx:22 X-Proofpoint-GUID: jBUzYxdTDKoopMA9O5Lzp8c65_U6PIUs X-Proofpoint-Spam-Info: AW1haW4tMjYwODExMDA3OCBTYWx0ZWRfXweuwfUcMB8lG Ep8R5jUyqALQ1hguCplxSzEuPjcCrUgR/ahBozg1nFtJ1odj0uoBLeSx0ryCM4HHaiYhQKErkup mxjoFJWi/Jpob69V+51WSCH37pFeHVw= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-10_06,2026-08-10_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 impostorscore=0 priorityscore=1501 bulkscore=0 spamscore=0 adultscore=0 suspectscore=0 malwarescore=0 lowpriorityscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608110078 On 8/10/2026 12:21 PM, Aniket Randive wrote: > The gpi_ch_init() error path has three bugs: sibling channels are May be instead of three bugs, can actually mention issues "start here mentioning the three problems first in generic way." is what i mentioned, not like write numbers :) . May be misunderstood. > not fully reset and deallocated, the event ring pm_state is left > stale after being freed, and ch_ring leaks if gpi_ch_init() fails. > > Fix the unwind loops in error_start_chan and error_alloc_chan to > iterate over gpii->gchan[i] instead of the original gchan pointer, > so each sibling channel is properly reset and deallocated. > > Restore pm_state to DISABLE_STATE after freeing the event ring, so > gpi_free_chan_resources() does not attempt to free an already freed > ring or issue a redundant EV_CMD_DEALLOC. > > Free ch_ring in gpi_alloc_chan_resources() if gpi_ch_init() fails, > since the ring is allocated before the call and would otherwise leak. > > Signed-off-by: Aniket Randive > --- Review if below looks fine, you may modify/change if anything wrong. you may wait for other's review and make changes together. Do not upload v3 only for this immediately. Title: Fix resource leaks in gpi_ch_init() error paths The gpi_ch_init() unwind paths do not clean up resources correctly when channel initialization fails. The error_start_chan and error_alloc_chan labels iterate over the original channel pointer instead of the channels stored in gpii->gchan[]. As a result, previously initialized sibling channels are not properly reset and deallocated. The event ring PM state is also left unchanged after the ring is freed. Subsequent cleanup through gpi_free_chan_resources() may therefore attempt to free the already released ring and issue a redundant EV_CMD_DEALLOC command. Additionally, gpi_alloc_chan_resources() allocates ch_ring before calling gpi_ch_init(), but does not release it when gpi_ch_init() fails, resulting in a memory leak. Fix the unwind paths to operate on the correct channels, restore the event ring PM state after freeing the ring, and release ch_ring when channel initialization fails.