Received: by 2002:ab2:69cc:0:b0:1fd:c486:4f03 with SMTP id n12csp181147lqp; Tue, 11 Jun 2024 00:40:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX2XK8qcmvwwB7RDZV0ZtQcTcw+RXkkCiXwNNBNlLP5K5esSZj+P4JMCSNXethRPzeAmVVcRCHelxvDUI1/etNy/5J6yZAn4rg6fato6A== X-Google-Smtp-Source: AGHT+IF9/uYqeWyTJmLCdMQi0FkZT2t1X1AyWCAYXIXS7ixPmhDkdGsWJDwjpkg7nhMDoxZsAWHe X-Received: by 2002:a05:6a20:9f88:b0:1b6:ea39:4d97 with SMTP id adf61e73a8af0-1b6ea394e91mr5605289637.29.1718091635123; Tue, 11 Jun 2024 00:40:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718091635; cv=pass; d=google.com; s=arc-20160816; b=S7Xg6FAuvNevjV1rz5xfhOAJ63tq0apHWaf42RKIiytt8d39/0QFJgVyhXwDnKAjSk cufTcpdM7iwYSAqBjdyi78jU5N/LeK+UE9h1qHfeKrbxZRQmNdrtLqHoU9fk3M+YLqJq bwhP5+k+iwworavo7bq4mS8kPb3Y4PvEPHX8VKB4xKiWLMQ5gPWCHfW+VHKCJ1WYZE78 tiD40G5vMiSuAZCb/U2xySUPe6AIHCSeX9OiW1WZoW/K/cv5X03ujQDLMQeXoZxfZ7hM bcWirIwkDQHBL5ppeDNN0UfdFvNoS1qKh4r6qDN1pUuu+nufvrM73dWj6xmHxDHR2HsF yckg== 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; bh=lpi2yZ9oanEz/CUi+BxEUDjmUJMQwCTWPzSOxXTgE18=; fh=pETW/XL/8YVQgjLsVPjqTY2s/bZ9V5kXNLKWPbIsDPs=; b=rea6GTfHXYT/59CXs3RitkcypXBWlazfzEqgXAliRg7O/kq9w7Sw6TW84sBu8RT9hn yEW+XjWWIaFijV68eCfB1nni0tHKBex1DPJkqncCBQd3OpNlcKufkiKaFcUpK2siomKo SpH/dU0Q+/MeFgq7fjrBT3uJSR4kT3S1oilW0TFrbdfb5BCUzVcSK3B3y45//DfHPn/j Mcvj3GeH09Lo9wfDXvjtnN5RMh6X2lhXn1urxhVOTZsVsl/1STgtSbmmrt59Dbju5oJv 9MSiyRRvfUGSJByi/HvqQzbVdHj4APWKtdy0zpL0FrST0wjNxaA0Mw6+94uFR/99Ei68 IPHg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=nfschina.com); spf=pass (google.com: domain of linux-kernel+bounces-209385-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-209385-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6e6bcb32889si6020370a12.332.2024.06.11.00.40.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 00:40:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-209385-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=nfschina.com); spf=pass (google.com: domain of linux-kernel+bounces-209385-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-209385-linux.lists.archive=gmail.com@vger.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 9A33E28B2AF for ; Tue, 11 Jun 2024 07:38:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8B266172BAB; Tue, 11 Jun 2024 07:38:04 +0000 (UTC) Received: from mail.nfschina.com (unknown [42.101.60.195]) by smtp.subspace.kernel.org (Postfix) with SMTP id 20A401E52F; Tue, 11 Jun 2024 07:37:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=42.101.60.195 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718091484; cv=none; b=XeSrzlstpx/h4PrUd6NC7o5ClPNlSG8n6x/njjHgdb+qymh+/VDw09vnWhqnsDbD9C3YLjw0pzU4ynk16rzwapNDIrib2wvgw/DGqPGW/v4QRxleHxU3VkDDZkg7PAxmyajjFNAIDHFWIlU8638dp6/TC0q++Kbt3C3Z9veoXkg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718091484; c=relaxed/simple; bh=72lUgCjhFS9CofYliVXKecRiALBrHqQMHHGrzotam3c=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=E+6y+rJwW1O1Reay45jEkx3EkDljJ/bE0yBbtHmRTwL4oH3a7BDocTArjiQP86u5ftSTIg0/f7wPwRN8KnsMWyJy1PXmkUh5/4daz+OsI1cn8zDpivf/4LCcIfYgnTLiwzD80ad4b7fPPQAbx3yg3WhDdo0RWRsCrEIlnlpYziQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nfschina.com; spf=pass smtp.mailfrom=nfschina.com; arc=none smtp.client-ip=42.101.60.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nfschina.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nfschina.com Received: from localhost.localdomain (unknown [180.167.10.98]) by mail.nfschina.com (Maildata Gateway V2.8.8) with ESMTPSA id 3201060198657; Tue, 11 Jun 2024 15:37:20 +0800 (CST) X-MD-Sfrom: suhui@nfschina.com X-MD-SrcIP: 180.167.10.98 From: Su Hui To: jonathan.derrick@linux.dev, axboe@kernel.dk, nathan@kernel.org, ndesaulniers@google.com, morbo@google.com, justinstitt@google.com Cc: Su Hui , jarkko@kernel.org, gjoyce@linux.vnet.ibm.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, kernel-janitors@vger.kernel.org Subject: [PATCH] block: sed-opal: avoid possible wrong address reference in read_sed_opal_key() Date: Tue, 11 Jun 2024 15:37:00 +0800 Message-Id: <20240611073659.429582-1-suhui@nfschina.com> X-Mailer: git-send-email 2.30.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Clang static checker (scan-build) warning: block/sed-opal.c:line 317, column 3 Value stored to 'ret' is never read. Fix this problem by returning the error code when keyring_search() failed. Otherwise, 'key' will have a wrong value when 'kerf' stores the error code. Fixes: 3bfeb6125664 ("block: sed-opal: keyring support for SED keys") Signed-off-by: Su Hui --- block/sed-opal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/sed-opal.c b/block/sed-opal.c index 14fe0fef811c..598fd3e7fcc8 100644 --- a/block/sed-opal.c +++ b/block/sed-opal.c @@ -314,7 +314,7 @@ static int read_sed_opal_key(const char *key_name, u_char *buffer, int buflen) &key_type_user, key_name, true); if (IS_ERR(kref)) - ret = PTR_ERR(kref); + return PTR_ERR(kref); key = key_ref_to_ptr(kref); down_read(&key->sem); -- 2.30.2