From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (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 38E1C22541C for ; Tue, 25 Nov 2025 16:06:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764086784; cv=none; b=piidt4JoN49SSItNa1aFHUHFE3dCX84Oe/Y1VtGIiq5LVz+9ZtVGzqmVGcJRcQi2G4wyecMPFQI6hkRCFQN5/22uOQpEYEoJehjHFFToCOE3NukayULO7Zj9h4UHD6x/Urmw9fLytBRg6gdERD+YLWq18LtVzLaRz5yfvGyX4bU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764086784; c=relaxed/simple; bh=jgsGJBsnCvaNQU+L+rBP1pJ53Y+2N8jfRU0bZti+g8Q=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=HoZBcSvmpkyouvZqs2qJu8Ev5OEPYclCsbabbH6MJtYWJsGBK7qLzeb+AANPEaCtBxA/GHremmModevr2uf7VOIf39smAiCjcRShRpqeEc2oXsP+xgV1IKoGPXxLZS7jj23DO4s5G4/IY7qJlrwF/Gyo4KQGYWoTgAeLWGi6Ws8= 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=mPgjB2Te; arc=none smtp.client-ip=209.85.210.170 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="mPgjB2Te" Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-7ba92341f83so8019794b3a.0 for ; Tue, 25 Nov 2025 08:06:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764086782; x=1764691582; darn=vger.kernel.org; h=content-transfer-encoding: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; bh=eo5CI+Lni0xfVNflA2YV6V9mRS/kG552howy/H4Z7eE=; b=mPgjB2TeSGbf8JtbZ6ncTLcED/OEIZF34pal3uI+cWCKBvIt213tcUtPQNwCYQ2oTJ eI8QYcaar5yR3W+fJLmyZPGYR0Kin91yeG+8eXyqIN5pBulyM1j740QptOKlMTeFcZq0 X09KuL1dE5V2KR3OdOx+CwQfX4dPK5YjphwvHvysxdKlhLGGXtXq5q3Q48kNp5CBF/U+ k0rV7DxT05/5STS5/Q0OOQifwsBzRgy4drJGQW4K+XzM5LKAKk/zneq4uZdye3Uu8vBR +xH0TkQhHiVcUXPEhSl+4/z7vbA7Fhq52BQTnQzdIuPurxfOvllW6+tTCbEZKXE4+Eke sr0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764086782; x=1764691582; h=content-transfer-encoding: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; bh=eo5CI+Lni0xfVNflA2YV6V9mRS/kG552howy/H4Z7eE=; b=rHAVjgf2fdd50hmsebNhnPJVKkp0R2fjphr3U6SKPdEphtcNRyA01Cd1vVRQgxQLTP Hr05s9a7ID9xAb+CB7BClCMKosPfM1wHqF27S27GXUNj4/b6s6YnRQJss5jmRL0Yni/m ILZLWNtp5jJ2Ju+F82kYu5bPvgu1UFq/vXQ1XeIb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:6a21:e098:b0:35d:1bcd:6874 with SMTP id adf61e73a8af0-3637db85c1emr3711017637.25.1764086781924; Tue, 25 Nov 2025 08:06:21 -0800 (PST) Received: from [192.168.2.119] ([103.92.100.163]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7c3ed471022sm18603626b3a.21.2025.11.25.08.06.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 25 Nov 2025 08:06:21 -0800 (PST) Message-ID: Date: Tue, 25 Nov 2025 21:36:16 +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] staging: most: dim2: fix missing cleanup on interface registration failure To: Abdun Nihaal Cc: parthiban.veerasooran@microchip.com, christian.gromm@microchip.com, gregkh@linuxfoundation.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org References: <20251122185656.251902-1-knavaneeth786@gmail.com> Content-Language: en-US From: Navaneeth K In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi Nihaal, Thank you for the detailed explanation. That makes perfect sense. I wasn’t aware that most_register_interface() is intended to handle cleanup via the dev.release path even on failure. I will analyze most_register_interface() and prepare a follow-up patch to address the inconsistency in the early error paths where put_device() is missing, as you suggested. Greg, since this version of the patch would introduce a double-free, could you please drop it from staging-testing? Regards, Navaneeth On 25-11-2025 20:46, Abdun Nihaal wrote: > nack. > > On Sat, Nov 22, 2025 at 06:56:56PM +0000, Navaneeth K wrote: >> If most_register_interface() fails, the function returned immediately >> without freeing the allocated 'dev' structure or resetting the hardware >> state via dim_shutdown(). > Based on the commit message of the following commit, > most_register_interface() is expected to free the passed interface using > device release both on success and error. > commit baadf2a5c26e ("most: usb: fix double free on late probe failure") > https://lore.kernel.org/all/20251029093029.28922-1-johan@kernel.org/ > >> dev->dev.release = dim2_release; >> >> - return most_register_interface(&dev->most_iface); >> + ret = most_register_interface(&dev->most_iface); >> + if (ret) >> + goto err_shutdown_dim; >> + >> + return 0; > Commit d445aa402d60 ("staging: most: dim2: use device release method") > converted this code to use device release, where the function stored in > dev.release (dim2_release() here) will be called to free the device > when put_device() or device_unregister() is called on the device. > > dim2_release() does free and shut down the hardware correctly, so doing > it again in the error path would lead to a double free. > > However, I do see that in most_register_interface() function, the first > few error paths (before the device_register() call) are not calling > put_device() to free the interface device, which is inconsistent with > the later error paths in that function. > > Leave this code as it is, and fix the most_register_interface() > to consistently release the device on error, by calling put_device() > on those early error paths. > > Also, when sending bug fixes, add a Fixes tag. > > Regards, > Nihaal