On Tue, Sep 01, 2026 at 05:29:46PM +0300, Jarkko Sakkinen wrote:
In all the pre-existing call sites both @iomem and @iobase_ptr are
either NULL or non-NULL.

I don't know this code, but I'm a bit worried about iobase_ptr and *iobase_ptr. IIUC it is true that iobase_ptr and iores are either NULL or non-NULL, but here we are removing the case where *iobase_ptr is NULL.

Now looking at crb_map_io(), IIUC iobase_array is initialized with NULL pointers and the code we are removing was the only one initializing those pointers IIUC, or am I missing something?

Thanks,
Stefano


Thus, add invariant for this and remove a dead basic block.

Signed-off-by: Jarkko Sakkinen <[email protected]>
---
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..e7a61f36c58b 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 == NULL) != (iobase_ptr == NULL))
+               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 via email to