From: Jarkko Sakkinen <jarkko@kernel.org>
To: linux-integrity@vger.kernel.org
Cc: Stefano Garzarella <sgarzare@redhat.com>,
Jarkko Sakkinen <jarkko@kernel.org>,
Peter Huewe <peterhuewe@gmx.de>, Jason Gunthorpe <jgg@ziepe.ca>,
Stuart Yoder <stuart.yoder@arm.com>,
"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
Chu Guangqing <chuguangqing@inspur.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH v2] tpm_crb: Remove dead code from crb_map_res()
Date: Sun, 11 Oct 2026 02:54:57 +0300 [thread overview]
Message-ID: <20261010235500.2915629-1-jarkko@kernel.org> (raw)
In all the pre-existing call sites both @iomem and @iobase_ptr are either
both NULL or have a valid address.
Add an invariant for the expeced conditions and remove a dead basic block.
The second block is dead given that if @iomem turns out not to be NULL,
neither can't be @iobase_ptr.
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
---
v2:
- Updated the commit message in order to clarify things better.
- Updated the invariant in order to address checkpatch.pl --strict
errors.
drivers/char/tpm/tpm_crb.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/char/tpm/tpm_crb.c b/drivers/char/tpm/tpm_crb.c
index ceb4100ba400..833226966fa2 100644
--- a/drivers/char/tpm/tpm_crb.c
+++ b/drivers/char/tpm/tpm_crb.c
@@ -570,15 +570,12 @@ static void __iomem *crb_map_res(struct device *dev, struct resource *iores,
if (start != new_res.start)
return IOMEM_ERR_PTR(-EINVAL);
+ if (!iores != !iobase_ptr)
+ return IOMEM_ERR_PTR(-EINVAL);
+
if (!iores)
return devm_ioremap_resource(dev, &new_res);
- if (!*iobase_ptr) {
- *iobase_ptr = devm_ioremap_resource(dev, iores);
- if (IS_ERR(*iobase_ptr))
- return *iobase_ptr;
- }
-
return *iobase_ptr + (new_res.start - iores->start);
}
--
2.47.3
reply other threads:[~2026-10-10 23:55 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261010235500.2915629-1-jarkko@kernel.org \
--to=jarkko@kernel.org \
--cc=chuguangqing@inspur.com \
--cc=jgg@ziepe.ca \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterhuewe@gmx.de \
--cc=rafael.j.wysocki@intel.com \
--cc=sgarzare@redhat.com \
--cc=stuart.yoder@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®