Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2083726lqb; Mon, 27 May 2024 07:23:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUdhyg/Pp6n9xGhYWAG8RnLgNVaDquVIB6oX10lJ5I0pmuZWLi0AiyPtxJPKSsZFMfc7jL22ajlCHSdcEAbDRdfG49le2tHRLDBln9LVA== X-Google-Smtp-Source: AGHT+IFzDGRnKbh0oMoW6CK2cLcmvdwBZksEX/1nrafnN7xJJ3JCWhrg4vTSe5GU24NE1NMDK2ch X-Received: by 2002:a05:6358:2787:b0:196:f08a:657d with SMTP id e5c5f4694b2df-197e50f3ce1mr762599555d.10.1716819797039; Mon, 27 May 2024 07:23:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716819797; cv=pass; d=google.com; s=arc-20160816; b=ygNtvuc+jOjuqZ8nLpVk5R6lFHx6ZCgWVpKed4XvJO9QPo4eWStu4uu6yRiSr3viit J6g4r0D8j5ILTmYoE8bbF5IGwKEHVZRbT8JpyFb8rDfuBIrPdNnZjg9pbUM8F6MP0pBe jkTPCv/4dTxnVDiwwVF3e5b3Co9pWg2UOePYjjezqxuoeBGFN4A3YiR68m9hhqVyJXgO y7yINkm4A0U7jfC3qgye1/gGDGtuwsHjKLwmhrrBs9qDpIWCObnYircRnlS6ZburIFwh TNewQbDkvwYSQQ3qjxBfYTb1r01GKoAoe3/vOxVk+jfRiA6nKLn+WMrbjoHY1eABedPV eBdQ== 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=JYQcsWsLTx5mY0zyWzeMEusfrAhzFo79kOBheqbowGQ=; fh=IDtux/UxPDq+waAlHOia+ycvtcO7CWKas2msTEvdUZQ=; b=iGgQl0u7Nh/tAzUtaKuWtg76desFDk+/prjdF5Q1YQHGqu6a3hovjENuRaaZsTuXRT kjmSEsAcN6gUzqB3Ws1MKlAa4CuFdJy2Tn7lINgxXrPjHPr270mhfu7Y8TxWVtcLwZUI o4zUYX/mu7ihiHF6/tAm8cBMmHjp1GSJeSCXKNksUPPKCYRkWIeEt9W8h1zvbB5CdWz9 AErGxIjAWBCWT/lgeQZOy2ufMNYuKBhO6LGtkcUTwqkiQSpG+LEn60Cb2nvJW1gvFG0c ERJyJhqRF9Fhz5xoE/kXiyfYhNyW3Qk1eCRVvWx7mTUD9i5ax7U6ck8uSzd35+PtnU0a D1CA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PeKKZVfM; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-190837-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190837-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-794abd50ec3si784949885a.588.2024.05.27.07.23.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 07:23:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-190837-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PeKKZVfM; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-190837-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190837-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 0D6581C21CDD for ; Mon, 27 May 2024 14:22:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A6AB51607B0; Mon, 27 May 2024 14:14:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PeKKZVfM" 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 CDEDF15EFDE; Mon, 27 May 2024 14:14:19 +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=1716819259; cv=none; b=KdNRffwZn/7Z2Rt6NosAwOeZsqqwZ/icVGJ4Puq7eM4t/KG8dPxWFk22+EkH8YP/QjLHKXqqD2hs6lb1E1NwiBl7rKUYOMnAYw2KIQWl84yqKXdGAzXhuWys+1WZHt/7jqBPxedvoT+gj6Vvs3Qc1IMiBEIRAdNM87bfcXr//Eg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716819259; c=relaxed/simple; bh=vcodY77d0fjdgiOcurVpNnSE7/ZF163gHw2AiqjgWxo=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=N5C6T0I4ELxtTS55TmotGfih4VMpdpcazm1TnzwelrvVL8ayrL1P0vClN3YDyppyzPxVhuRwO3HKCIHSefiwZJMnWqX9xPhulkGBoeDZrM0ABmoDY5LmH9OWolk+UgZU1rw6iaYxUCaV/D72Zc/q/loqmoWIqV2wMan5OaJvHNE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PeKKZVfM; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id F26D5C2BBFC; Mon, 27 May 2024 14:14:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716819259; bh=vcodY77d0fjdgiOcurVpNnSE7/ZF163gHw2AiqjgWxo=; h=From:To:Cc:Subject:Date:From; b=PeKKZVfMpw1Z9ACDnUUgNKU4ArPn4gpsQrLMDIiQiVyQwuUwQaHj73afr2Xgr/xhn UNonDSouZ4GzEyfGliud+4Fl6GOPiWHSqbdsYFuIXnpSGcZDhz/CncugQiV+dV+Qk3 VxNlwYp0OOFdVhDsQOL3pbEHxhWbyifFLMYji7/iQQ5bUs011VsWjP0z1oPNUcoTLh V+VJCwPB47iaI47v/I+e2jKIoRnCW8oDHutQjfMB5Ix7A6X/7JhaMHqpAdkcWcZRDi ZjDGpTI2bzGKGhl26jg5JtzH+jnohqhzaNp95fDoslAFC+y9HbChtme0r1n2IKwjFe GboLVx1RzFqag== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Rand Deeb , Kalle Valo , Sasha Levin , linux-wireless@vger.kernel.org Subject: [PATCH AUTOSEL 6.8 01/30] ssb: Fix potential NULL pointer dereference in ssb_device_uevent() Date: Mon, 27 May 2024 10:13:10 -0400 Message-ID: <20240527141406.3852821-1-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.8.11 Content-Transfer-Encoding: 8bit From: Rand Deeb [ Upstream commit 789c17185fb0f39560496c2beab9b57ce1d0cbe7 ] The ssb_device_uevent() function first attempts to convert the 'dev' pointer to 'struct ssb_device *'. However, it mistakenly dereferences 'dev' before performing the NULL check, potentially leading to a NULL pointer dereference if 'dev' is NULL. To fix this issue, move the NULL check before dereferencing the 'dev' pointer, ensuring that the pointer is valid before attempting to use it. Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Rand Deeb Signed-off-by: Kalle Valo Link: https://msgid.link/20240306123028.164155-1-rand.sec96@gmail.com Signed-off-by: Sasha Levin --- drivers/ssb/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/ssb/main.c b/drivers/ssb/main.c index b9934b9c2d708..070a99a4180cc 100644 --- a/drivers/ssb/main.c +++ b/drivers/ssb/main.c @@ -341,11 +341,13 @@ static int ssb_bus_match(struct device *dev, struct device_driver *drv) static int ssb_device_uevent(const struct device *dev, struct kobj_uevent_env *env) { - const struct ssb_device *ssb_dev = dev_to_ssb_dev(dev); + const struct ssb_device *ssb_dev; if (!dev) return -ENODEV; + ssb_dev = dev_to_ssb_dev(dev); + return add_uevent_var(env, "MODALIAS=ssb:v%04Xid%04Xrev%02X", ssb_dev->id.vendor, ssb_dev->id.coreid, -- 2.43.0