From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-177.mta0.migadu.com (out-177.mta0.migadu.com [91.218.175.177]) (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 380953A1A59 for ; Tue, 21 Apr 2026 09:24:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776763481; cv=none; b=eIldtpXVwdXevut+6KW2yCNcTxASSPS4Rdvg6CTkhZ8FBjXYQhySD9uHyxjkKHlRCbq3W/KGIcbARQd0+mEbSwczflAMjz17JvEa41cBQPm8sAyjYTiLpYuuHRC4Uiezc+LmvRDJKSbBiKflZUdTm3iEfdj4uC7Dnb7JoNI4euI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776763481; c=relaxed/simple; bh=Veg603++04a4fI/yjvEyxIJqvWDUP5efJnLCMaX/2Ac=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=EI+4vTUZ6UP8cqmqSv/SHjDvjO+KJNOGo1H9nYCVCySSuQ7aHoeH9So7K18vhXonEyc/8aKan8vqyOuXeKtzlNEtZKTsdr2Dm9QJ7S4aE+masLJhYs83UzygQ3vwsN8OpRrVhzurbvDokvacxJ2N/KLOssTzQGhMU6swgwxEufQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=sDKPqO15; arc=none smtp.client-ip=91.218.175.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="sDKPqO15" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1776763476; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=HiP8U7iGEUV5KD2PR2peIpyqYDO8dPS6Jb55P5tW2xQ=; b=sDKPqO15yxDQDgq29M/FJJcQagAX05sQkWB524huZmWB2TQOYvPwLVQIW2jeaaJarQ6Fh8 Upf4q3ez6j0yQohn3f0cgiB2yWcbQGuv/QfZbRh5Jczh0zkdB4va5y0U/yiUI+Jeiqjy11 L3dl2yeB8/OZNZrjqAICty6CU+SVg2I= From: sunliming@linux.dev To: miklos@szeredi.hu, amir73il@gmail.com Cc: linux-unionfs@vger.kernel.org, linux-kernel@vger.kernel.org, sunliming Subject: [PATCH] ovl: Fix possible NULL pointer dereference in ovl_destroy_inode Date: Tue, 21 Apr 2026 17:23:49 +0800 Message-Id: <20260421092349.148002-1-sunliming@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT From: sunliming In the ovl_destroy_inode function, a variable reference oi->lowerdata_redirect that might be NULL is directly freed. Add a non-null check, and only free the space when it is not NULL. Signed-off-by: sunliming --- fs/overlayfs/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c index 60f0b7ceef0a..4b8b5fd4ab59 100644 --- a/fs/overlayfs/super.c +++ b/fs/overlayfs/super.c @@ -218,7 +218,7 @@ static void ovl_destroy_inode(struct inode *inode) ovl_stack_put(ovl_lowerstack(oi->oe), ovl_numlower(oi->oe)); if (S_ISDIR(inode->i_mode)) ovl_dir_cache_free(inode); - else + else if (oi->lowerdata_redirect) kfree(oi->lowerdata_redirect); } -- 2.25.1