Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp362299lqj; Sun, 2 Jun 2024 01:46:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUdjAAoJ951F5wCrNcnTI9Z1DpxD36J4AJMtJdwq66hh5lFjhUhPFfs73CoE3xwy+BuPpME0y8aErrk5leoV7gkpxN/LlYAp3JX8ny3lw== X-Google-Smtp-Source: AGHT+IE0hdoXnxGSX1Mc+ilSh4mQ3+6iSnKoxVBfuSi8+yA4UK6V0N3GIx+Wha2EdSYKJChv6Pii X-Received: by 2002:a05:6a20:914d:b0:1a7:5fe0:1c99 with SMTP id adf61e73a8af0-1b26f25cef3mr6985935637.46.1717318013971; Sun, 02 Jun 2024 01:46:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717318013; cv=pass; d=google.com; s=arc-20160816; b=z0yfqqb5hR2f559tmvL3sL93b1XCqU0L9Tk6g1gozXS6sZQ6lUyWkG1l+PxjBVPKZa Pmcyn1rtxf/jUS9QAIjBlPn2PgtGhd22Ip7JeY9HYWk9CYJ/p/YmTANZl2Dn1u7WILaw Nm8sGPdSE5FibMYAe3/8uW5RRGUzNE4V2b9Tzc8ZO1vyjMmfhMK3mSGcRnCsp9e4VZoa p0K9iUevtAjWuYoe3NrY8YGSqa093kDg/EG/ZLIBhiuQDT7YztBlyZgqhEoCEjgZ5m4d 0Fru3bgNCJb6oqleZgDCxE0aCkPeK5D9Cfq2bk6GbgqFVUftRMppz6aI7/EgZaedxD6k DRGA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=JftoCKvTUzwdjKYhGR/l+pUm3JyDm2uIElHiFV8nCTA=; fh=TbprZbvgcUR/aJbAyTwPQpFw15iERWv797sTl73qJcI=; b=wHaO1IDE8d5qoKy/v8R8jX2EN77LJmlvmK2QHG6Rgn2U6aD7qWIdNSSswi3wPYAp8z kBn8uIgR/eHaezEE7k/AXqZkR3qhZvllJzJBa5Rp05p69m/4h0MFyJ8S7Fom19YehCby PLdWGBwyelTqBrIa1TSGM18MQ5HbnECG3fLDbg9p85ujYW3z4uiCdM421qSrpcJWYoPS Y4FdVB3X3FCoGu+d6HrNujMW8GvO7eRnGbeF/5xGUOq19/C/xT4foC5yzi16bfLv8SxW F6HRoTc3jh8u/TxyXFQ58vsW+z/k0NZsGWVBArJwv6PbgetM4h0lYnM98KC8sKb7Pd5i aR0Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=E7nY9xR0; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-198161-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-198161-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 41be03b00d2f7-6c359e09e15si4502941a12.272.2024.06.02.01.46.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Jun 2024 01:46:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-198161-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=E7nY9xR0; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-198161-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-198161-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id D2E93B2105C for ; Sun, 2 Jun 2024 08:46:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9AFDA23767; Sun, 2 Jun 2024 08:46:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="E7nY9xR0" Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) (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 8DC903207; Sun, 2 Jun 2024 08:46:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.194 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717317986; cv=none; b=syG2l2vjqNVdJT68iVzlrKiCjvJj5gl+GvSmF+xx4MwvIWjOnfmlHWBGD67wTKd0/i26+4DD2jurNwp3CJD2Kr3fJgJEFaoMddNIc28z/zN6+E+o73VH7koZJJ8rsG+I4EUNghKHfRiLetc9l14Lk1MGgkl/6d6WBH6idXZcUvs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717317986; c=relaxed/simple; bh=M9OoV4npu3Dnivv/rLY2zwxANqupb8d/T3cQUBqyDNY=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=OELfmCx54LujXHy3CCK94z0pKoeeBNI1EaL8PBCsz3t8zLPesN/Fj/BXSRIfTqBg3npS+5QRKsqYCegYJ7gAGL6mPa2U2/pyupwRaOkncGJwUt+OFWg96efzkXhus7ZTwXnDrpBqfFFkOA+K77YV9eZH/wBNN3Z4jjT9DzxH9bg= 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=E7nY9xR0; arc=none smtp.client-ip=209.85.214.194 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 Received: by mail-pl1-f194.google.com with SMTP id d9443c01a7336-1f44b441b08so26332775ad.0; Sun, 02 Jun 2024 01:46:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717317985; x=1717922785; 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=JftoCKvTUzwdjKYhGR/l+pUm3JyDm2uIElHiFV8nCTA=; b=E7nY9xR0becU9QWvV/IOp6mRVJH4mJ404+wqiBa0Uv6abl4zTvwOjlOzQUNtykEzrJ +u+tf1QMbr2+dwwDZilUetEA9A/KYT7xgX2u1S+H80oQFbkf7e6UoBw6aU21icd5XDti Y52LomViWo7VL4n+hLREwCVnGV73059Dd7QUgo7jsSPEFhWQ0i1mzQjWO/sQmf+mHBOJ ZuidmFBz38sDb7YxdHgwN+Q1zPi1LCJuKQdElAUwM18abSgJu8Axc1wNR8+6t1hpH3sZ kzly6MvUzU2NqrXmPb5Pb7E8L7Dvc1DdZHmgUAjvJANNO6fT4OcIu31I2Hzc6dF0vAYw 3slQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717317985; x=1717922785; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=JftoCKvTUzwdjKYhGR/l+pUm3JyDm2uIElHiFV8nCTA=; b=f4W7IsPC2OpY4ttG7eGYDXylYrbX3DNQpogyyE1dwcZLmBzgpsKQ0wBqan8vM6iw/b mQNWVj6h16GUPmr29tDlxuImlMEv/ok4L+ZjpEH8apO4IV9msYgdisfZVqclthSXYVwj PWjquFHEEt4+H85lIIGCzf9QsQjsHBufMifNbC1YKu1feAlkKzxE5uCMFJyxZ0ZzeUkH S3MuibREcUqcS6g4OHqTJqe4eSSAv2/H00wKh6CO1c5TAJXCSIAVTUBwzxDM4RoccnFM nBVFrxBkzcqnOL8RNKj3Z1rroUzz8sXr29MvJJTRfzGUC4xVsIdvDecWc7VUcoX3dX2z ccpA== X-Forwarded-Encrypted: i=1; AJvYcCVbpEpyuMyO3RJcIELy8PP2sKQRx3sjf/lBNjf39BtOU3qrH9f7DMUgpwaWP6UyAkUs/JS0bHKPZzriO+xmIJGnkUbDAgWuk0vVqFxZqaMd3HhEpJsI8Q2S/n2Vql84EM8NBZ51iyMBpfo= X-Gm-Message-State: AOJu0YzpdZO3PHsPM7qm262mjjHsGSJ/3fJ0mbe9VBrgpVrOTZP/NKqn +e3+SW3uJLBi8kEMMRfOOvqQ+xajylWDr5xO5aLR7fQXMZ3naEsx X-Received: by 2002:a17:902:f805:b0:1f4:6c83:23d3 with SMTP id d9443c01a7336-1f6370bcd33mr55691915ad.52.1717317984654; Sun, 02 Jun 2024 01:46:24 -0700 (PDT) Received: from lhy-a01-ubuntu22.. ([106.39.42.164]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f6323eb1fdsm44248015ad.204.2024.06.02.01.46.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Jun 2024 01:46:24 -0700 (PDT) From: Huai-Yuan Liu To: thierry.reding@gmail.com, mperttunen@nvidia.com, airlied@gmail.com, daniel@ffwll.ch, jonathanh@nvidia.com Cc: dri-devel@lists.freedesktop.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, baijiaju1990@gmail.com, Huai-Yuan Liu Subject: [PATCH V2] drm/tegra: fix a possible null pointer dereference Date: Sun, 2 Jun 2024 16:46:13 +0800 Message-Id: <20240602084613.220931-1-qq810974084@gmail.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit In malidp_tegra_crtc_reset, new memory is allocated with kzalloc, but no check is performed. Before calling __drm_atomic_helper_crtc_reset, mw_state should be checked to prevent possible null pointer dereference. Fixes: b7e0b04ae450 ("drm/tegra: Convert to using __drm_atomic_helper_crtc_reset() for reset.") Signed-off-by: Huai-Yuan Liu --- V2: * In patch V2, we call __drm_atomic_helper_crtc_reset(crtc, NULL) when state is null. Thanks to Thierry Reding for helpful suggestion. --- drivers/gpu/drm/tegra/dc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c index be61c9d1a4f0..afa7c269c29a 100644 --- a/drivers/gpu/drm/tegra/dc.c +++ b/drivers/gpu/drm/tegra/dc.c @@ -1388,7 +1388,10 @@ static void tegra_crtc_reset(struct drm_crtc *crtc) if (crtc->state) tegra_crtc_atomic_destroy_state(crtc, crtc->state); - __drm_atomic_helper_crtc_reset(crtc, &state->base); + if (state) + __drm_atomic_helper_crtc_reset(crtc, &state->base); + else + __drm_atomic_helper_crtc_reset(crtc, NULL); } static struct drm_crtc_state * -- 2.34.1