Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2268796iof; Wed, 8 Jun 2022 00:59:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy01+O+AcGjhnWWVakOAIhVwALN7DOjxnsJBaLThKteAhAHybEiVfFiV2qdQRpRsC6OsoMa X-Received: by 2002:a17:90b:4a0a:b0:1e8:5078:b573 with SMTP id kk10-20020a17090b4a0a00b001e85078b573mr24370774pjb.213.1654675168465; Wed, 08 Jun 2022 00:59:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654675168; cv=none; d=google.com; s=arc-20160816; b=00vQk6JBVdRZtVyaldqOXCAC9Sj7Xt7xSszp0jVHghlm9Y0xEtrzos6RVDGKCVZM+8 erKPz76VJYaaYvqo+DLydiwYAhRR/SB8I/Tf+EDw3BqK9Z8v8m+DXJuL+gfzUwufg+lf 1tSeTvp47eYVe9NaJb3Fu78VNnK/oC7kq3Imw4tZrnvP1BRsvDaKQlt4BG9sp+jh8HjZ j7M2cUjNz3HzKw5DsGofsD4Ok5+NHs1blELd5AWWjdU5meTQS5lkWUYxOm+FdR0vwwe+ hBkGhbVrzYh4S4Chl4yQvcwwOFELul9eLQTrmISwZdM4pbnHbJ88neMVl8JQV89KGp04 NW/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=oeMDVDhVm5YXqjmGLIxZ4CII7+RZDzsZ6msY7Om6us0=; b=gPuLSbE2LJ285n+RZeUsrk+LSSVSlSsUj6tlTS9yFQ0Ysbw2wmjsZq1GPLAYXIY07e Fz6MRDsEWdMDchTqc6uVWsq/gb6sXVEhtQPJRS98u0lBk0WJKgt62kdTODd7rByqlmTr chRyxLiriu6sWv4bjOiSQincE96JSMDxUnGQrxsrOzrvnFCaUfZ7M56ssGqTL8B8nPOw 6Qje2Q+gv4XL2DDkXYhl6ehkRa7qZX3RlBNXFwGHpu14htgqyWgOdHyRvMiYqGHJutaN DTorZ5safT2YhViqMqJAk/vMAv3vGumHicrgS7NjXN6pTVH3gDRqJkmO62/odWVGo0F3 yN9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DsMkhhbx; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id m11-20020a637d4b000000b003f9e159641fsi28115761pgn.663.2022.06.08.00.59.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 00:59:28 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DsMkhhbx; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 103BA1E5611; Wed, 8 Jun 2022 00:29:22 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380971AbiFGWWt (ORCPT + 99 others); Tue, 7 Jun 2022 18:22:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380728AbiFGVQy (ORCPT ); Tue, 7 Jun 2022 17:16:54 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DC3E21F9E1; Tue, 7 Jun 2022 11:56:46 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CDE7A61794; Tue, 7 Jun 2022 18:56:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DD1FAC385A2; Tue, 7 Jun 2022 18:56:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654628205; bh=iNHK4FsWAeAmGLGVXN+d7gkN/OJ8GAY1t4eehMHASVA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DsMkhhbx1YaGIOiuB8rTCaIEodtZSB/sMvClPuSJq+mz0eWRNRh0RGitVv9d6GyTu kJWPhHNzvll44DgjFLyqUNMlfW/qrQtc7OTX2iVW9EXbxxuZv05u6PRt5wEMi5dbBI XtCZy+C3aB1MGs023KIin9edWxVA3KrZFVnsDNsc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Jarkko Sakkinen , Sasha Levin Subject: [PATCH 5.18 203/879] char: tpm: cr50_i2c: Suppress duplicated error message in .remove() Date: Tue, 7 Jun 2022 18:55:21 +0200 Message-Id: <20220607165008.738250110@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Uwe Kleine-König [ Upstream commit e0687fe958f763f1790f22ed5483025b7624e744 ] Returning an error value in an i2c remove callback results in an error message being emitted by the i2c core, but otherwise it doesn't make a difference. The device goes away anyhow and the devm cleanups are called. As tpm_cr50_i2c_remove() emits an error message already and the additional error message by the i2c core doesn't add any useful information, change the return value to zero to suppress this error message. Note that if i2c_clientdata is NULL, there is something really fishy. Assuming no memory corruption happened (then all bets are lost anyhow), tpm_cr50_i2c_remove() is only called after tpm_cr50_i2c_probe() returned successfully. So there was a tpm chip registered before and after tpm_cr50_i2c_remove() its privdata is freed but the associated character device isn't removed. If after that happened userspace accesses the character device it's likely that the freed memory is accessed. For that reason the warning message is made a bit more frightening. Signed-off-by: Uwe Kleine-König Signed-off-by: Jarkko Sakkinen Signed-off-by: Sasha Levin --- drivers/char/tpm/tpm_tis_i2c_cr50.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/char/tpm/tpm_tis_i2c_cr50.c b/drivers/char/tpm/tpm_tis_i2c_cr50.c index f6c0affbb456..bf608b6af339 100644 --- a/drivers/char/tpm/tpm_tis_i2c_cr50.c +++ b/drivers/char/tpm/tpm_tis_i2c_cr50.c @@ -768,8 +768,8 @@ static int tpm_cr50_i2c_remove(struct i2c_client *client) struct device *dev = &client->dev; if (!chip) { - dev_err(dev, "Could not get client data at remove\n"); - return -ENODEV; + dev_crit(dev, "Could not get client data at remove, memory corruption ahead\n"); + return 0; } tpm_chip_unregister(chip); -- 2.35.1