From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ED28833A03D for ; Wed, 18 Feb 2026 09:14:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771406059; cv=none; b=arvwxaY8OXGwX+ml/ABAQRNGxfh0bMVs/fnrjSwu6NhdZM3/WHr36k9s8+mOimJ5vujE1M0dFidz4NkxqQDDQ/qMVN+GaUHoZGP2Yaw6dVEXrEUyPVTZ/xPKFrxOYlUAkaunkurngivwR1tMTa/bn/31RpkvXHUpiiIWcVdBNhc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771406059; c=relaxed/simple; bh=K1fkG5xJAYeAu2Jz3+lOBCdudWVHy6/ylSrbbO0iXBs=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=swWKhF/K+fzx8o4MxozCzp+h260UykPB7twr9JCnIXnBcDen7fHdfGfW1lIUiXv7WVRj+FGdkM8ZMyzuUp0gW9hopUdr0FUXmMLMISIjPq/+GOGhsfl68tbk/koBIYRGC1JXAdnMW/ndgu3VaIh4sPpHSsu/8AZQvXnB+r39YCc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=kOMf9NuY; arc=none smtp.client-ip=209.85.221.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kOMf9NuY" Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-436309f1ad7so4085936f8f.3 for ; Wed, 18 Feb 2026 01:14:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771406055; x=1772010855; darn=vger.kernel.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=K1fkG5xJAYeAu2Jz3+lOBCdudWVHy6/ylSrbbO0iXBs=; b=kOMf9NuYg5Ir/TEv8MD93LQO4gNblmeWdXEUI7bQgf9+dHUekb/CowPyny8OrhHoEq YUT6DiFjA5hO/kP9cEyvcW7qkr6syjqjLWcn98o8BJRST3F1iKReWErTJYNrrV5yqy9O 9p9p27Gf8n/AACGoKR37elouiLumTEnXXP+Bz69vj9Ux9J7W/J7kE+yyLbwTdYX8LKQR e43xvN2I9dWXjaSmhgbbcK1+XSOvpXXKtsWduPsiMySDKOeEpSD9671v+f4g9Zi93I6R p2LiAsHopHxSKZzKmkk4GZ6ECsnC5533t4ieI8XTFh2Kg4asYMipYltFQhmg2ubZbyZY p+Uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771406055; x=1772010855; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=K1fkG5xJAYeAu2Jz3+lOBCdudWVHy6/ylSrbbO0iXBs=; b=VIp//kjNqqIpAt+5GQ/ZM/aCUS46ps/D3gnt4418Dy6DLAWWpA+J5yFFjZ9KuyoQHH QL+EySC5TcJM9Zs2+FtueN0CAKwt0F1FvhAgzMrM/lGilULDMi8CZ7SQG9quFtMJF9f4 M/hhTxTGJ3dvMVIyPHTx02dm00sg7UYgMxIuxDM+ZOfMxP9rubhpow562Jd5LtFAPZPp 3fVnPNMyUWlBgXhy9bWtXciBAaT8aPWK3W/HBZN9uedaahCVb0ZizoDvmYpUBwk3FNi0 u5XWhhSJRhWVNEmJ4N/bCR9ZE09ZDChmg5uQdi6coBZ4kYr+45PmXK46pBqzkpFt9vHQ 7Ljw== X-Forwarded-Encrypted: i=1; AJvYcCUOlHgGcQowb+0/+f7LtXrtnggDkh41vOtWz3z0Lt/d8OIFmQnX7VhfHb+eI4jWlWDpG5uRgBFjzUvQ84U=@vger.kernel.org X-Gm-Message-State: AOJu0YyS5wpplPjygpnyhfCG+v0dge6cGFVLpnc0Aqn/6hwxYa1pCvhr fZZ5B+o75yIQu8CvBfPi9egHMdekP9VO9BCI/rQLvLmy+0Y3VdilFtIE X-Gm-Gg: AZuq6aINRON/yJ0428dAIIy0jUD5CxyA3evJ6sNw10nZDfv/Sxpfn9tZgxGr1HXL7OH FnsqcgQAxuUf0vNYA0q1Gi6DxWiUh1MeDhZBHsLHWjCNFPVdeDnY393BlQJVOgIsP6sJfouNn6n hDWRUMbRxlvrdfJvwvU0Rlhax4TAPmX7t6RPeZyyaZ/3jbw1Bs4QQcDxPy9IW0sczHx8E3mFOgl GhOM3lN+RxrOOmTXccAmXlb03oVlLX4i1zc/AA2dL06wmo1YdW8ZUiBEvxyEDfLBc5QM0pJrgxl 4qmTxu4qQSYlQhU+KGOY9UqYTDLglShKz0wrGUv/4ZFawmked6hSkUKB/D8fIw/hBOoAbEKBCtD HeIKFs/LW/3EHztz7yuO3SgCA3574LocU0sIBOPVOCi6VhFsDiYNavKJkR2vVWQq5OvxPPrLvej 1J/U5Zx8mlkc0X5Nbf9TImf+QRkg8KS1g= X-Received: by 2002:a5d:64e7:0:b0:437:8f98:8c91 with SMTP id ffacd0b85a97d-4379db34172mr23918370f8f.3.1771406054907; Wed, 18 Feb 2026 01:14:14 -0800 (PST) Received: from [192.168.1.187] ([148.63.225.166]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43796ad009bsm39228886f8f.39.2026.02.18.01.14.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Feb 2026 01:14:14 -0800 (PST) Message-ID: Subject: Re: [PATCH v3] iio: trigger: use put_device() in viio_trigger_alloc() error path From: Nuno =?ISO-8859-1?Q?S=E1?= To: Andy Shevchenko Cc: Salah Triki , Jonathan Cameron , David Lechner , Nuno =?ISO-8859-1?Q?S=E1?= , Andy Shevchenko , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Date: Wed, 18 Feb 2026 09:14:57 +0000 In-Reply-To: References: <20260215222348.186806-1-salah.triki@gmail.com> <96b05a514d229b23ea0917447607dd7390ec0e2e.camel@gmail.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.58.3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Tue, 2026-02-17 at 17:08 +0200, Andy Shevchenko wrote: > On Tue, Feb 17, 2026 at 01:51:08PM +0000, Nuno S=C3=A1 wrote: > > On Mon, 2026-02-16 at 09:45 +0100, Salah Triki wrote: > > >=20 > > > You are absolutely right. My previous version (v3) was logically flaw= ed as > > > it could trigger the release callback before the necessary fields wer= e > > > initialized, leading to an unsafe irq_free_descs() call. > > >=20 > > > Since I don't have the physical hardware to perform runtime injection > > > tests,I relied on manual code path analysis and clearly failed to acc= ount > > > for the side effects of put_device(). > > >=20 > > > I'm sending a v4 which takes the safer approach: moving > > > device_initialize() after all potential failure points. This way, we = can > > > safely use kfree() and irq_free_descs() in the error path without > > > involving the device lifecycle prematurely. > > >=20 > > > Thank you for the catch. > >=20 > > Please just use the same approach Andy did for iio_device_alloc(). I po= sted > > links (in one of your versions) to that and for the discussion we alrea= dy had > > on this same function some time ago. >=20 > I believe this is the approach mentioned above, id est move device_initia= lize() > further in the code. But I might misread something... Me too. But if that was the case, I would not expect any put_device() call.= Ah, but I just read Salah's reply. It will be done in v4. - Nuno S=C3=A1