From: <ye.xingchen@zte.com.cn> To: <andrew@lunn.ch> Cc: <gregory.clement@bootlin.com>, <sebastian.hesselbarth@gmail.com>, <linux@armlinux.org.uk>, <linux-arm-kernel@lists.infradead.org>, <linux-kernel@vger.kernel.org> Subject: [PATCH] ARM: mvebu: potential dereference of null pointer Date: Thu, 19 Jan 2023 10:51:18 +0800 (CST) [thread overview] Message-ID: <202301191051184033370@zte.com.cn> (raw) From: Minghao Chi <chi.minghao@zte.com.cn> The return value of kzalloc() needs to be checked. To avoid use of null pointer in case of the failure of alloc. Reported-by: Zeal Robot <zealci@zte.com.cn> Signed-off-by: Minghao Chi <chi.minghao@zte.com.cn> Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn> --- arch/arm/mach-mvebu/board-v7.c | 4 ++++ arch/arm/mach-mvebu/coherency.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/arch/arm/mach-mvebu/board-v7.c b/arch/arm/mach-mvebu/board-v7.c index fd5d0c8ff695..3c031b2efe16 100644 --- a/arch/arm/mach-mvebu/board-v7.c +++ b/arch/arm/mach-mvebu/board-v7.c @@ -125,11 +125,15 @@ static void __init i2c_quirk(void) struct property *new_compat; new_compat = kzalloc(sizeof(*new_compat), GFP_KERNEL); + if (!new_compat) + return; new_compat->name = kstrdup("compatible", GFP_KERNEL); new_compat->length = sizeof("marvell,mv78230-a0-i2c"); new_compat->value = kstrdup("marvell,mv78230-a0-i2c", GFP_KERNEL); + if (!new_compat->name || !new_compat->value) + return; of_update_property(np, new_compat); } diff --git a/arch/arm/mach-mvebu/coherency.c b/arch/arm/mach-mvebu/coherency.c index a6b621ff0b87..8291185c52cc 100644 --- a/arch/arm/mach-mvebu/coherency.c +++ b/arch/arm/mach-mvebu/coherency.c @@ -191,7 +191,11 @@ static void __init armada_375_380_coherency_init(struct device_node *np) struct property *p; p = kzalloc(sizeof(*p), GFP_KERNEL); + if (!p) + return; p->name = kstrdup("arm,io-coherent", GFP_KERNEL); + if (!p->name) + return; of_add_property(cache_dn, p); } } -- 2.25.1
WARNING: multiple messages have this Message-ID (diff)
From: <ye.xingchen@zte.com.cn> To: <andrew@lunn.ch> Cc: <gregory.clement@bootlin.com>, <sebastian.hesselbarth@gmail.com>, <linux@armlinux.org.uk>, <linux-arm-kernel@lists.infradead.org>, <linux-kernel@vger.kernel.org> Subject: [PATCH] ARM: mvebu: potential dereference of null pointer Date: Thu, 19 Jan 2023 10:51:18 +0800 (CST) [thread overview] Message-ID: <202301191051184033370@zte.com.cn> (raw) From: Minghao Chi <chi.minghao@zte.com.cn> The return value of kzalloc() needs to be checked. To avoid use of null pointer in case of the failure of alloc. Reported-by: Zeal Robot <zealci@zte.com.cn> Signed-off-by: Minghao Chi <chi.minghao@zte.com.cn> Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn> --- arch/arm/mach-mvebu/board-v7.c | 4 ++++ arch/arm/mach-mvebu/coherency.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/arch/arm/mach-mvebu/board-v7.c b/arch/arm/mach-mvebu/board-v7.c index fd5d0c8ff695..3c031b2efe16 100644 --- a/arch/arm/mach-mvebu/board-v7.c +++ b/arch/arm/mach-mvebu/board-v7.c @@ -125,11 +125,15 @@ static void __init i2c_quirk(void) struct property *new_compat; new_compat = kzalloc(sizeof(*new_compat), GFP_KERNEL); + if (!new_compat) + return; new_compat->name = kstrdup("compatible", GFP_KERNEL); new_compat->length = sizeof("marvell,mv78230-a0-i2c"); new_compat->value = kstrdup("marvell,mv78230-a0-i2c", GFP_KERNEL); + if (!new_compat->name || !new_compat->value) + return; of_update_property(np, new_compat); } diff --git a/arch/arm/mach-mvebu/coherency.c b/arch/arm/mach-mvebu/coherency.c index a6b621ff0b87..8291185c52cc 100644 --- a/arch/arm/mach-mvebu/coherency.c +++ b/arch/arm/mach-mvebu/coherency.c @@ -191,7 +191,11 @@ static void __init armada_375_380_coherency_init(struct device_node *np) struct property *p; p = kzalloc(sizeof(*p), GFP_KERNEL); + if (!p) + return; p->name = kstrdup("arm,io-coherent", GFP_KERNEL); + if (!p->name) + return; of_add_property(cache_dn, p); } } -- 2.25.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next reply other threads:[~2023-01-19 2:51 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-01-19 2:51 ye.xingchen [this message] 2023-01-19 2:51 ` [PATCH] ARM: mvebu: potential dereference of null pointer ye.xingchen 2023-01-19 13:38 ` Andrew Lunn 2023-01-19 13:38 ` Andrew Lunn 2023-01-19 18:01 ` Russell King (Oracle) 2023-01-19 18:01 ` Russell King (Oracle) -- strict thread matches above, loose matches on Subject: below -- 2023-01-21 1:37 kernel test robot 2023-01-17 10:22 ye.xingchen 2023-01-17 10:22 ` ye.xingchen 2023-01-18 13:17 ` Andrew Lunn 2023-01-18 13:17 ` Andrew Lunn
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=202301191051184033370@zte.com.cn \ --to=ye.xingchen@zte.com.cn \ --cc=andrew@lunn.ch \ --cc=gregory.clement@bootlin.com \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux@armlinux.org.uk \ --cc=sebastian.hesselbarth@gmail.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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.