linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vc04_services: vchiq_arm: fix a NULL pointer dereference
@ 2019-03-24 22:43 Kangjie Lu
  2019-03-25  9:15 ` Stefan Wahren
  2019-03-27 14:49 ` Mukesh Ojha
  0 siblings, 2 replies; 3+ messages in thread
From: Kangjie Lu @ 2019-03-24 22:43 UTC (permalink / raw)
  To: kjlu
  Cc: Stefan Wahren, devel, Greg Kroah-Hartman, Phil Elwell,
	linux-kernel, Tobias Büttner, Eric Anholt, Luis Chamberlain,
	linux-rpi-kernel, pakki001, Dominic Braun, Nicolas Saenz Julienne,
	linux-arm-kernel

When kzalloc fails, "platform_state->inited = 1" is a NULL pointer
dereference. The fix returns VCHIQ_ERROR in case it failed to
avoid NULL pointer dereference.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
 .../staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c  | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
index dd4898861b83..0f12fe617575 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
@@ -209,6 +209,8 @@ vchiq_platform_init_state(struct vchiq_state *state)
 	struct vchiq_2835_state *platform_state;
 
 	state->platform_state = kzalloc(sizeof(*platform_state), GFP_KERNEL);
+	if (!state->platform_state)
+		return VCHIQ_ERROR;
 	platform_state = (struct vchiq_2835_state *)state->platform_state;
 
 	platform_state->inited = 1;
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] vc04_services: vchiq_arm: fix a NULL pointer dereference
  2019-03-24 22:43 [PATCH] vc04_services: vchiq_arm: fix a NULL pointer dereference Kangjie Lu
@ 2019-03-25  9:15 ` Stefan Wahren
  2019-03-27 14:49 ` Mukesh Ojha
  1 sibling, 0 replies; 3+ messages in thread
From: Stefan Wahren @ 2019-03-25  9:15 UTC (permalink / raw)
  To: Kangjie Lu
  Cc: devel, Greg Kroah-Hartman, Phil Elwell, linux-kernel,
	Tobias Büttner, Eric Anholt, Luis Chamberlain,
	linux-rpi-kernel, pakki001, Dominic Braun, Nicolas Saenz Julienne,
	linux-arm-kernel

Hi Kangjie,

Am 24.03.19 um 23:43 schrieb Kangjie Lu:
> When kzalloc fails, "platform_state->inited = 1" is a NULL pointer
> dereference. The fix returns VCHIQ_ERROR in case it failed to
> avoid NULL pointer dereference.
>
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
please add a proper fixes tag.
> ---
>  .../staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c  | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
> index dd4898861b83..0f12fe617575 100644
> --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
> +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
> @@ -209,6 +209,8 @@ vchiq_platform_init_state(struct vchiq_state *state)
>  	struct vchiq_2835_state *platform_state;
>  
>  	state->platform_state = kzalloc(sizeof(*platform_state), GFP_KERNEL);
> +	if (!state->platform_state)
> +		return VCHIQ_ERROR;

this change is good, but vchiq_init_state doesn't bail out immediately
in case vchiq_platform_init_state fails.

Could you please fix that, too?

Thanks Stefan

>  	platform_state = (struct vchiq_2835_state *)state->platform_state;
>  
>  	platform_state->inited = 1;


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] vc04_services: vchiq_arm: fix a NULL pointer dereference
  2019-03-24 22:43 [PATCH] vc04_services: vchiq_arm: fix a NULL pointer dereference Kangjie Lu
  2019-03-25  9:15 ` Stefan Wahren
@ 2019-03-27 14:49 ` Mukesh Ojha
  1 sibling, 0 replies; 3+ messages in thread
From: Mukesh Ojha @ 2019-03-27 14:49 UTC (permalink / raw)
  To: Kangjie Lu
  Cc: Stefan Wahren, devel, Greg Kroah-Hartman, Phil Elwell,
	linux-kernel, Tobias Büttner, Eric Anholt, Luis Chamberlain,
	linux-rpi-kernel, pakki001, Dominic Braun, Nicolas Saenz Julienne,
	linux-arm-kernel


On 3/25/2019 4:13 AM, Kangjie Lu wrote:
> When kzalloc fails, "platform_state->inited = 1" is a NULL pointer
> dereference. The fix returns VCHIQ_ERROR in case it failed to
> avoid NULL pointer dereference.
>
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>


Reviewed-by: Mukesh Ojha <mojha@codeaurora.org>

-Mukesh

> ---
>   .../staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c  | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
> index dd4898861b83..0f12fe617575 100644
> --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
> +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
> @@ -209,6 +209,8 @@ vchiq_platform_init_state(struct vchiq_state *state)
>   	struct vchiq_2835_state *platform_state;
>   
>   	state->platform_state = kzalloc(sizeof(*platform_state), GFP_KERNEL);
> +	if (!state->platform_state)
> +		return VCHIQ_ERROR;
>   	platform_state = (struct vchiq_2835_state *)state->platform_state;
>   
>   	platform_state->inited = 1;

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-03-27 14:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-24 22:43 [PATCH] vc04_services: vchiq_arm: fix a NULL pointer dereference Kangjie Lu
2019-03-25  9:15 ` Stefan Wahren
2019-03-27 14:49 ` Mukesh Ojha

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).