Received: by 2002:a05:7412:7c14:b0:fa:6e18:a558 with SMTP id ii20csp393979rdb; Mon, 22 Jan 2024 07:29:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IEWWA6IvZ8uiirAsH8aKHrhtT5GVi4Sn/cbhNCfhfBiCC4RVHXvy+cC6Otvka94TWmiiqmn X-Received: by 2002:a17:906:1855:b0:a30:461d:5c56 with SMTP id w21-20020a170906185500b00a30461d5c56mr939337eje.91.1705937358594; Mon, 22 Jan 2024 07:29:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705937358; cv=pass; d=google.com; s=arc-20160816; b=YfwX/IV+RYYk3PGuIzu7Rj8DaaE2dVwg1+gpWAdydr57Zyn55w8W1jcxjB+yRzG436 4Yaus2mFItn09uYUq0WmW7XVriyzhWIwKEQZM5ujyBwKsDF6vPIdOfemSMW5h8eWdLVR dgk6wPgMSiR2AyFlXKwGzmWDCg2ix+tuv79Mw0Um/ch/pZT3eH8UIuyydUwHuM/UI42Q 7hY8ulbvmv6dM23TBMea8bprxghAvePDdvrOcyNwGpNU83IPGI+2UB6PJr4w2R9Fj/8m R/HCgXjwL+rdYAjrsqVpfnrM3dEL+9InopHO26CHIJ180OlbYxGxPG0KShzUjA5mWLGP wQhQ== 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=III91drXQYsr0sNU+pJ2l/Cr0LmMBw9R4Xt1plUHvWc=; fh=9HcSl/Iz02SM6CmZgPXu5x8JpGN3TYsCBiXIfrgbpbw=; b=hcipuMbR3tF5xHhtpCQlRCplaVIxZDqGV7lb/FZMU4ADbhAlFAH2goXfdE1Hduu4c0 WOGvdgjoonfqldVz+m0P9eozPxMGUHc4QGFKdjHFuvyvCISQxagzVf7KqWPKKSElTpVc /9CSe/84h33zyT8az7qq3i3iqxDF2cHqer66ce/fzQ/5/Gz5BubXkzcaF8JGmCLBhDcf B5l5MeTDkA7NRuNoS/l7W+hSB9AJGha+1T8eQk8ttEl4HlT/8oRNUkeM6dqhmqA9jANP a3dimIqeIutJr7jPHBoS6BGVG8KwflVoudJds+pFW8q1L9Jfk67pmIRrDoCiKCckcHqu VzZQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dasyUWBS; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-33300-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-33300-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id l2-20020a170906414200b00a2db48077a3si8193792ejk.350.2024.01.22.07.29.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 07:29:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-33300-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dasyUWBS; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-33300-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-33300-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 87D4A1F2653B for ; Mon, 22 Jan 2024 15:28:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E72895F54F; Mon, 22 Jan 2024 15:01:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dasyUWBS" 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 1E28D5F545; Mon, 22 Jan 2024 15:01:51 +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=1705935711; cv=none; b=rnHK8pPgW1RPxeaXHEjAGiQYxvzdjyyyYtmugRaaq2AutiDiiDKPnW2mnS0xhRXOkRCa2oVi+6yiXiRoh1k5G+2xlu/voqNUK5DsAE+UJ2/G4uV/NNyHkrNVqKzyC36IvknRcWUung2yJf/svmdg11jBvQkg3ssL2y3rQPrPLnE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705935711; c=relaxed/simple; bh=ZsYhDRSMrBrkpdbxY5l+VFbJSu4rGbvydsbzY2yWMBk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pl3KUeLxAos/PCkoDujQikv0a08V2O53GdBU1kVGPfmXtxD4vskt1aMbuFiLTjNK4NgSlyk0n450f1YC/gZU86CvAmDlssa/lQJA+pKEDIWI1iQdGJzQSWHRoeF9+YlLembIKxeQ5X+u43DoweoLLSyJvmHzSy2Y5g/NXLgHjmo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dasyUWBS; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3A31C433A6; Mon, 22 Jan 2024 15:01:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705935710; bh=ZsYhDRSMrBrkpdbxY5l+VFbJSu4rGbvydsbzY2yWMBk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dasyUWBShZhR7APwOFg8w8yqjG9yLSohFK/DEKbt5owa+ZbXkkZPuelAY5YNHJ1ts 4Bf98sQUdoPr/r3OzcBwcveNAFPVcPvYEvm2eOsy7g8F3RSkCMYwl1XpDLP3X767jZ wsaUkmfFKdzpGgZ88+bYdkLpoYwei/mLQQCNgkHGkaWCv38O3yxHHVlE9lnPM/qTaP zlHrCfmYD0aNRe+ew9SvKMaLBkAJvys3HtxEUdyQQE+zG2oniBecJ+CpaWju1KmVTx oeWNM3U12ZmJErYqukUTKSTUMwxAA/PxmgimrUl0/qHh+cvOtp0J6ryB6a2GevZkUl uBq+LM0/eFoAg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Srinivasan Shanmugam , Hawking Zhang , Tao Zhou , =?UTF-8?q?Christian=20K=C3=B6nig?= , Alex Deucher , Sasha Levin , Xinhui.Pan@amd.com, airlied@gmail.com, daniel@ffwll.ch, Stanley.Yang@amd.com, kevinyang.wang@amd.com, YiPeng.Chai@amd.com, asad.kamal@amd.com, lijo.lazar@amd.com, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 6.7 78/88] drm/amdgpu: Fix possible NULL dereference in amdgpu_ras_query_error_status_helper() Date: Mon, 22 Jan 2024 09:51:51 -0500 Message-ID: <20240122145608.990137-78-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240122145608.990137-1-sashal@kernel.org> References: <20240122145608.990137-1-sashal@kernel.org> 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=UTF-8 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.7.1 Content-Transfer-Encoding: 8bit From: Srinivasan Shanmugam [ Upstream commit b8d55a90fd55b767c25687747e2b24abd1ef8680 ] Return invalid error code -EINVAL for invalid block id. Fixes the below: drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c:1183 amdgpu_ras_query_error_status_helper() error: we previously assumed 'info' could be null (see line 1176) Suggested-by: Hawking Zhang Cc: Tao Zhou Cc: Hawking Zhang Cc: Christian König Cc: Alex Deucher Signed-off-by: Srinivasan Shanmugam Reviewed-by: Hawking Zhang Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c index 63fb4cd85e53..4a3726bb6da1 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c @@ -1174,6 +1174,9 @@ static int amdgpu_ras_query_error_status_helper(struct amdgpu_device *adev, enum amdgpu_ras_block blk = info ? info->head.block : AMDGPU_RAS_BLOCK_COUNT; struct amdgpu_ras_block_object *block_obj = NULL; + if (blk == AMDGPU_RAS_BLOCK_COUNT) + return -EINVAL; + if (error_query_mode == AMDGPU_RAS_INVALID_ERROR_QUERY) return -EINVAL; -- 2.43.0