From nobody Sun Feb 8 14:35:31 2026 Received: from mail-yw1-f193.google.com (mail-yw1-f193.google.com [209.85.128.193]) (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 D40E7329E79 for ; Thu, 8 Jan 2026 19:45:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767901509; cv=none; b=YskX/2i+PtspafWk4fJ+q8sxvgxhKluC/mSeef2+qaeZ2kHkQKakO+t8C2/V5veBsp8FAtDR1bmXI1ypl4Zqhox6WiV56MIXBR7o2zYZeUKtKSVaesXfVLn4n+zY1D9LI/k8PmOeuel5qk8xhiJanCy8MnR8cCAT+zOmnDE9fUE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767901509; c=relaxed/simple; bh=eAVXXyiGbN3gTusm+7x6VDyeyT4fFgfgDOvEzLPeHHI=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=e4LsOHfQ6+Sc+QzMm42nS1ZopPl1dQpA0hSAidI1h43DZCicQOk4keqWJ8hsKS4u8wifjfv/Xmr2hhrNnuY4upsSOPcxeG3cRwVykUVWOoQGK1rQ0Ju0YStEg8uKGdpPPOi92G4RU7hRWrunHeEHZTB/BRKjSlwsNwSMrTSXS2c= 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=P8tHwPyt; arc=none smtp.client-ip=209.85.128.193 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="P8tHwPyt" Received: by mail-yw1-f193.google.com with SMTP id 00721157ae682-78fb7ab7562so31909337b3.2 for ; Thu, 08 Jan 2026 11:45:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767901506; x=1768506306; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=zo5T6K6ayd5ZE20he6Wo4qsE1omj9FzcArZuU+4F42I=; b=P8tHwPytv/qzJX48vxDbJMydLKv1PEBxl1fTy672cixJAo0KyqjKkmB2+btUzNxT5F Rlsu8eWYJEtgl3TpwW9xut26S+ZH7Axhrltqi+TZqTMDAhcIsg2fDV2xt0yLqniRL/qq qDrVwvvjbkNCV+HeV7fCTClLm68QFCSFc9iOdkUrYxd67WxH/RwS2/zbeT5FyXhQCSKJ NhpIkCeIaykxRV1EirkEFPN+dsjYoBYlqq1qqZmFjqXRw0QWxYzZNlbiAikGBhckVgGU mbvI/jKw9VvuwW/6NaNWUETcZZSxsL/Zc+lrntEI5n4OZ98+T12vLSRwIVWA3KAdFLAx F4Gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767901506; x=1768506306; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=zo5T6K6ayd5ZE20he6Wo4qsE1omj9FzcArZuU+4F42I=; b=Bydsb3DrW6WVXWvtSJAuICsoneLiGhinC56ts+4jlR52Y7RshXCB8GuNDcOf89ZBNF abEf36rOmO/ecfHQGDziOrc6v+22bZOujdYDK9ZMzkxoYEnoYmFP9Y1s7Nmj3+3zC5yd XpKtMjEakhbdlEG0jYA3H/26yN2IlBBoBS3Qt86/wNgAQbYZEaXg1rPYoiAJL4CZgF5C B369HKETM6e/pp5Iq2Iz+aCsOLEmMOBMHdYRVF0/Yu8GtJhytnfjOuUVLL6pF2IAYf/P eK7Z300C2IRQ2jfJLJ4OOOuV2EWlUBRelbncwYOieBh95a3F71NKYTxfLZjnqp0lDgfb bv9w== X-Forwarded-Encrypted: i=1; AJvYcCUm8fX9MPP3mmxXXtw1dyCrnyoQ4JcQGAGSri05uMgurX8GNLB04/deVnOb0sSsR5aDcTWze8AEgnx+Ex8=@vger.kernel.org X-Gm-Message-State: AOJu0YzuFilxtKPYyPhug8loSBRfk7vU2i5D9HTdj/YzfvdeUSsdkV3T uD+DkD/ZlfIn9cGPl82pJzM7VcDOmn+pMYBzqXuWr5MlxieOBBUc1OQ5a6YroxNQ X-Gm-Gg: AY/fxX4m1rBSdS6kZsGswmcWdAAz4Dricd6rhvp4MLkc2bxZRsiS1RiKIX9xu5nLk/f ANcy4o223x87a4uqh1Pw+Bk+92bUcaQxqzWnB77bHmfqzgw3NuyaGx71he8FbzzvnENK8+c1TYU CAVFh0x1Ma3SteXkrne9SVeB2WjrMZVw7fxrEBp/qfswtl7SR1pIWjFo85QVWHdzkHA8bAWXMws Ajf83z1kFWDjAybftlxjqkbWXkBjDvF+wY5C5wK90NLb2tMD3SrEjlAPxDJ8agNFt1AcrICx8iG CwpYHugiBMd0oHSrRDpr2ygDJE9Tq6lJZVIDIPe8+SB9kCF8bXcEY4qmt2azwDwJ/u4SLHT08gZ lOoQO/mfrtOWVldM1h3I17JVSPIn0KUFYujp0u8MCeIEx3jBU8vDPtkn3Q9ya8zyYjstWXgqvrX TqDbxIAFfsDH/U3IyTzRbnzG7jlfE6n3bv X-Google-Smtp-Source: AGHT+IE3UY4+w0Ahx9+y2qVFAJb5T0udRQIuPVyTVXULTkItYhhorY9Vi9pr50wpMhWj4BWeB3PF5w== X-Received: by 2002:a05:690c:30c:b0:78f:a81a:6f6b with SMTP id 00721157ae682-790b5800c9dmr151764697b3.32.1767901505782; Thu, 08 Jan 2026 11:45:05 -0800 (PST) Received: from newman.cs.purdue.edu ([128.10.127.250]) by smtp.gmail.com with ESMTPSA id 00721157ae682-790aa6a3969sm32752087b3.43.2026.01.08.11.45.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jan 2026 11:45:05 -0800 (PST) From: Jiasheng Jiang To: Chris Mason , David Sterba Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, Jiasheng Jiang Subject: [PATCH] btrfs: add missing ASSERT for system space_info in reserve_chunk_space Date: Thu, 8 Jan 2026 19:45:02 +0000 Message-Id: <20260108194502.653-1-jiashengjiangcool@gmail.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In reserve_chunk_space(), btrfs_find_space_info() is called to retrieve the space_info for the SYSTEM block group. However, the returned pointer is immediately dereferenced by spin_lock(&info->lock) without validation. While the SYSTEM space_info is expected to be present during normal operations, direct dereference without checking creates a risk of a null pointer dereference. This deviates from the coding pattern seen in peer functions like btrfs_chunk_alloc() where such returns are validated with an ASSERT. Add an ASSERT() to ensure the pointer is valid before access, improving code robustness and consistency with the rest of the block-group logic. Signed-off-by: Jiasheng Jiang --- fs/btrfs/block-group.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c index 08b14449fabe..f4229ee4f573 100644 --- a/fs/btrfs/block-group.c +++ b/fs/btrfs/block-group.c @@ -4313,6 +4313,7 @@ static void reserve_chunk_space(struct btrfs_trans_ha= ndle *trans, lockdep_assert_held(&fs_info->chunk_mutex); =20 info =3D btrfs_find_space_info(fs_info, BTRFS_BLOCK_GROUP_SYSTEM); + ASSERT(info); spin_lock(&info->lock); left =3D info->total_bytes - btrfs_space_info_used(info, true); spin_unlock(&info->lock); --=20 2.25.1