* [PATCH] i2c: mux: reg: Fix possible null-ptr-deref
@ 2022-11-14 0:43 Hui Tang
2022-12-07 20:22 ` Wolfram Sang
0 siblings, 1 reply; 2+ messages in thread
From: Hui Tang @ 2022-11-14 0:43 UTC (permalink / raw)
To: peda; +Cc: linux-i2c, linux-kernel
It will cause null-ptr-deref when resource_size(res) invoked,
if platform_get_resource() returns NULL.
Fixes: b3fdd32799d8 ("i2c: mux: Add register-based mux i2c-mux-reg")
Signed-off-by: Hui Tang <tanghui20@huawei.com>
---
drivers/i2c/muxes/i2c-mux-reg.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/i2c/muxes/i2c-mux-reg.c b/drivers/i2c/muxes/i2c-mux-reg.c
index 0e0679f65cf7..d26de1017385 100644
--- a/drivers/i2c/muxes/i2c-mux-reg.c
+++ b/drivers/i2c/muxes/i2c-mux-reg.c
@@ -184,12 +184,12 @@ static int i2c_mux_reg_probe(struct platform_device *pdev)
dev_info(&pdev->dev,
"Register not set, using platform resource\n");
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- mux->data.reg_size = resource_size(res);
mux->data.reg = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(mux->data.reg)) {
ret = PTR_ERR(mux->data.reg);
goto err_put_parent;
}
+ mux->data.reg_size = resource_size(res);
}
if (mux->data.reg_size != 4 && mux->data.reg_size != 2 &&
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] i2c: mux: reg: Fix possible null-ptr-deref
2022-11-14 0:43 [PATCH] i2c: mux: reg: Fix possible null-ptr-deref Hui Tang
@ 2022-12-07 20:22 ` Wolfram Sang
0 siblings, 0 replies; 2+ messages in thread
From: Wolfram Sang @ 2022-12-07 20:22 UTC (permalink / raw)
To: Hui Tang; +Cc: peda, linux-i2c, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 454 bytes --]
On Mon, Nov 14, 2022 at 08:43:22AM +0800, Hui Tang wrote:
> It will cause null-ptr-deref when resource_size(res) invoked,
> if platform_get_resource() returns NULL.
>
> Fixes: b3fdd32799d8 ("i2c: mux: Add register-based mux i2c-mux-reg")
> Signed-off-by: Hui Tang <tanghui20@huawei.com>
Correct, yet I applied this older patch instead:
http://patchwork.ozlabs.org/project/linux-i2c/patch/20221029093825.3425857-1-yangyingliang@huawei.com/
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-12-07 20:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-14 0:43 [PATCH] i2c: mux: reg: Fix possible null-ptr-deref Hui Tang
2022-12-07 20:22 ` Wolfram Sang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox