From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.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 B6A3834F48D for ; Mon, 13 Apr 2026 10:27:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776076078; cv=none; b=hr0rZ1OEvPhTtnDnnTAO7Cz3lcEhvx00WauUeKSPE2uGhecimEOPFt6XeYYNitFnI9txo602hChFsGU1AJh6Gh56LXGUxQQzjMPHFCjG3h0R4aPpbGhoSmtwKI0VDb7hPjSltT6nedY65dNWqn34zAgM8Swkw1qzM5ER7mqehOA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776076078; c=relaxed/simple; bh=Wo/H3nkvnYfDOPwSOhXRPoLWQlF4HiLgzcjjj9Gxy8g=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Eczh/rrF8JO9oYyxR66SpPqz8PwGVhjBCsGSS6tFWhMr2oPKWuf4JQAfIqrV8kl/eEcgIqwKW0rEobXn9B1JZZ5byHdXXapg/eldxZ3xcJXMmzEUj3EmpAy4rc8zoHsY3Wi+w7RCGQuiXK2peZoEmSe9iNxgz2Vu3/d2pQr1XbU= 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=GFRIa/2+; arc=none smtp.client-ip=209.85.128.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="GFRIa/2+" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-488aa77a06eso72142525e9.0 for ; Mon, 13 Apr 2026 03:27:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776076075; x=1776680875; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=5191h31g8rBCcVHs7mCj4zrQVM2ZH4x8IA2+cTQ4Cgw=; b=GFRIa/2+8eoylbPLMYgSpjZu9Aksf8Nq5Of1pU1DarZT213iUBysz+WftoFkibL+Nl /aQD/KqpjcIhTIRWJzq90FZE/VCTV1r2srZGYdduUtgsY86GnXHlDm4jca3CQX4jyzUt qOlo4kgu4B6TaY4EMvOdNQVoYk22hBhweq0GsFHWBycIv0OdrGbsaGkM7wnmc1fNd5Si b1N4Mt07WtvEIppTAw5owiNvAuvMlh656rVME67fF/QGfRWl5M1r6n8mUJIVnFQAN2OA QBKy42gbdcEpFPlUEhEsEIWn6WnPdk9P+wfGXoGHPFBuTXQWp4jeKBpgDGK+Py2P5/Ws z0mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776076075; x=1776680875; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5191h31g8rBCcVHs7mCj4zrQVM2ZH4x8IA2+cTQ4Cgw=; b=YzRYw8jPl0mSP8IVIaaxVV6GtOk2gPFWpnXv9ytmAwZPX5BdRMInVWi/L/8gCgKyYt WDhUb3AHsXPCXF9/3chRYQRLWONEDlN4NTtTLnGu9GUJzphzb2kVZwDxdO4Nfb0PpqZI 1MMFRy+Qx1//Kw3zzwMsco0a7Pn/4Spg8viRVlDSuT973fwGF9pDJlwOI2Rybsji325S kuybNwbcNPZWdcgeCyTazcC/iFjmu/7rhex66B8L+5OEEDvw2l5K20PrBb3kFSF0JjM0 qaomM1jF4+q5ItyR2d+j2JvUrd5BvRVtr0EdSbii3y0iMyy5QM5vh3tuNLp/CGlxdes0 l8RA== X-Forwarded-Encrypted: i=1; AFNElJ8WdzdnyHDSRJnmsF/En8skwKuoGGPrT39v35Hc+vBaHI9zB8jscaXFhhpyHdzmNR/Sg3JPn4EpqAtL1nA=@vger.kernel.org X-Gm-Message-State: AOJu0YyY0s998e4OapNJmSdPJxoVWqpGkVhmJhG5dMhcCysb53UODtlj GdRmWdi+LjuMun8ccJtuf+Lx6Vf82KSThftI36eq2E1Eh3NsC3cka/s/ X-Gm-Gg: AeBDiesBT0OAJ9BjxS9z15Kz9qxOH4o9M1/DulE/8klrtPXT1cmM5JSphWYQBOftTNK YCDTbbehKCpeQs+WPN456d1EjrOd9xlUZTr471rbb1+MYyHcIdSQrggmEKkyNryQzzeER1FfZFO E2LW+cmFV0tf61fG77DvgTKlC/VEAigZggEWHYj2EgFDUmowVvjzH9AuLIc5L2EjW9QIs0bRVZ+ nD7LlcAmmlVarnU7zN24EZTkN3oQ0TdDgkpBETuejS6DNhz59FPqa15osZ8LK71vlZG1hNVyoDj Ahj5lBbcx9M18YzqsN67+I9SrHCw8lgjoyhpD5omU+eD71nRDlxZj5CgTW42ZdtDBdB1IiGZQNO GJbf/pA0g9UmiCUnGrohUXTibtyb1gGMFUZJfhU1TyffSZcToErkonSogIJb3/Mcqpw7R5Hs09t rJjRpHSEXEQSNGFfR3lIE= X-Received: by 2002:a05:600c:4987:b0:488:def6:bb17 with SMTP id 5b1f17b1804b1-488def6bce5mr60305855e9.4.1776076075070; Mon, 13 Apr 2026 03:27:55 -0700 (PDT) Received: from localhost ([196.207.164.177]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-488d66773c8sm203145935e9.0.2026.04.13.03.27.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2026 03:27:53 -0700 (PDT) Date: Mon, 13 Apr 2026 13:27:50 +0300 From: Dan Carpenter To: Alexandru Hossu Cc: linux-media@vger.kernel.org, sakari.ailus@linux.intel.com, bingbu.cao@intel.com, mchehab@kernel.org, gregkh@linuxfoundation.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] staging: media: ipu7: fix double-free and use-after-free in error paths Message-ID: References: <20260412205057.386856-5-hossu.alexandru@gmail.com> <20260413101533.496090-1-hossu.alexandru@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@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: <20260413101533.496090-1-hossu.alexandru@gmail.com> On Mon, Apr 13, 2026 at 12:15:33PM +0200, Alexandru Hossu wrote: > In both ipu7_isys_init() and ipu7_psys_init(), pdata is allocated and > then passed to ipu7_bus_initialize_device(), which stores it in > adev->pdata. The ipu7_bus_release() function frees adev->pdata when the > device's reference count drops to zero. > > Two error paths incorrectly call kfree(pdata) after the device teardown > has already freed it: > > 1. When ipu7_mmu_init() fails: put_device() is called, which drops the > reference count to zero and triggers ipu7_bus_release() -> > kfree(pdata). The subsequent kfree(pdata) is a double-free. > > 2. When ipu7_bus_add_device() fails: it calls auxiliary_device_uninit() > internally, which calls put_device() -> ipu7_bus_release() -> > kfree(pdata). The subsequent kfree(pdata) is again a double-free. > > Note that the kfree(pdata) when ipu7_bus_initialize_device() itself > fails is correct, because in that case auxiliary_device_init() failed > and the release function was never set up, so pdata must be freed > manually. > > Additionally, the error code was not saved before calling put_device(), > causing ERR_CAST() to dereference the already-freed adev pointer when > constructing the return value. Fix this by saving the error from > dev_err_probe() before put_device() and returning ERR_PTR() instead. > > Remove the redundant kfree(pdata) calls and fix the use-after-free in > the return values of the two affected error paths. > > Fixes: b7fe4c0019b1 ("media: staging/ipu7: add Intel IPU7 PCI device driver") > Signed-off-by: Alexandru Hossu > --- Both the resent patches are fine now. Reviewed-by: Dan Carpenter However, please could you resend the whole patch series as a new thread (with the first two or whatever dropped)? regards, dan carpenter