From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 D532834E769; Wed, 25 Feb 2026 14:16:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772029017; cv=none; b=En43EljuSM+n30iJVvV3rMcF4mCWFCieSVI3hBNNPh6vRHZgqwHfC37PJbI+deMZCaSF8MgOetVAgIFb6YchqXf++n1Er3qqNb2Tw078GaUWVjOUdYTzheDUnY20yQDhHDtY6z2xkdkeTYzS1vXg+rWxbxgdU8bHlGy6TOksybg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772029017; c=relaxed/simple; bh=Cn/P13jzPyGCU7lYYVNN1npFey8dA1wOd1XPu1CYI6c=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=sYMGzzY0BmNGzRh1F5PugWLG8L1cPMER+n9UnD+sVU9Zhklxaqy7wfYqMweWs4Z7hZ/Fd8TuWvLe1L3H6TLx3lAndHSHXdCuw2R4nvNrSOfQitns9mAx7fG93hLE0qdgM4WZrMgYPO8GKZBgmdwKFZVzENEffAahTWL8WHqV6ao= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Bic4zeMd; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Bic4zeMd" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6E075C116D0; Wed, 25 Feb 2026 14:16:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1772029017; bh=Cn/P13jzPyGCU7lYYVNN1npFey8dA1wOd1XPu1CYI6c=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Bic4zeMdQgeYUrRSTMLjo+IXkkSWqxItxTz4ZqpkVtWhGA0j4jkqeoWnfjZXNrwKF C0B9w4btbefSLfibhMgqXTAQcI8r40nDw8tvLPturbHzET8LLqSIo2zc0ZgxwxkmCr aHhllnFIOnt2lFfTPDs/4ohPvSwA/CPuyU2/a/2U= Date: Wed, 25 Feb 2026 06:16:50 -0800 From: Greg Kroah-Hartman To: Guangshuo Li Cc: Yaxing Guo , linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH] uio: uio_pci_generic_sva: fix double free of devm_kzalloc() memory Message-ID: <2026022502-buckshot-unlovable-35a6@gregkh> References: <20260225132737.4176605-1-lgs201920130244@gmail.com> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260225132737.4176605-1-lgs201920130244@gmail.com> On Wed, Feb 25, 2026 at 09:27:36PM +0800, Guangshuo Li wrote: > uio_pci_sva allocates struct uio_pci_sva_dev with devm_kzalloc() in probe(), but then calls kfree(udev) both on the probe() error path (label out_free) and again in remove(). > Because devm_kzalloc() allocations are devres-managed and are freed automatically when the device is detached, which also happens after a failing probe() and during driver unbind, the explicit kfree() can result in a double free. If probe() fails after devm_kzalloc(), the error path kfree(udev) frees the object, and devres cleanup will free it again when the core unwinds the partially bound device. On normal driver removal, remove() explicitly frees udev, and devres will free it again when the device is detached. Something went wrong here, please wrap your changelog text at 72 columns. > Fix by removing the manual kfree() calls and dropping the now-unused label. > > Fixes: 3397c3cd859a2 ("uio: Add SVA support for PCI devices via uio_pci_generic_sva.c") > Cc: stable@vger.kernel.org > Signed-off-by: Guangshuo Li How was this found and tested? thanks, greg k-h