netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch 1/2] rocker: add a check for NULL in rocker_probe_ports()
@ 2015-02-25 13:35 Dan Carpenter
  2015-02-25 13:46 ` Scott Feldman
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Dan Carpenter @ 2015-02-25 13:35 UTC (permalink / raw)
  To: Jiri Pirko; +Cc: Scott Feldman, netdev, kernel-janitors

Make sure kmalloc() succeeds.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/net/ethernet/rocker/rocker.c b/drivers/net/ethernet/rocker/rocker.c
index 34389b6a..713a13c 100644
--- a/drivers/net/ethernet/rocker/rocker.c
+++ b/drivers/net/ethernet/rocker/rocker.c
@@ -4201,6 +4201,8 @@ static int rocker_probe_ports(struct rocker *rocker)
 
 	alloc_size = sizeof(struct rocker_port *) * rocker->port_count;
 	rocker->ports = kmalloc(alloc_size, GFP_KERNEL);
+	if (!rocker->ports)
+		return -ENOMEM;
 	for (i = 0; i < rocker->port_count; i++) {
 		err = rocker_probe_port(rocker, i);
 		if (err)

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

* Re: [patch 1/2] rocker: add a check for NULL in rocker_probe_ports()
  2015-02-25 13:35 [patch 1/2] rocker: add a check for NULL in rocker_probe_ports() Dan Carpenter
@ 2015-02-25 13:46 ` Scott Feldman
  2015-02-25 13:55 ` Jiri Pirko
  2015-02-27 20:59 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Scott Feldman @ 2015-02-25 13:46 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Jiri Pirko, Netdev, kernel-janitors

On Wed, Feb 25, 2015 at 5:35 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> Make sure kmalloc() succeeds.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/drivers/net/ethernet/rocker/rocker.c b/drivers/net/ethernet/rocker/rocker.c
> index 34389b6a..713a13c 100644
> --- a/drivers/net/ethernet/rocker/rocker.c
> +++ b/drivers/net/ethernet/rocker/rocker.c
> @@ -4201,6 +4201,8 @@ static int rocker_probe_ports(struct rocker *rocker)
>
>         alloc_size = sizeof(struct rocker_port *) * rocker->port_count;
>         rocker->ports = kmalloc(alloc_size, GFP_KERNEL);
> +       if (!rocker->ports)
> +               return -ENOMEM;
>         for (i = 0; i < rocker->port_count; i++) {
>                 err = rocker_probe_port(rocker, i);
>                 if (err)

Acked-by: Scott Feldman <sfeldma@gmail.com>

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

* Re: [patch 1/2] rocker: add a check for NULL in rocker_probe_ports()
  2015-02-25 13:35 [patch 1/2] rocker: add a check for NULL in rocker_probe_ports() Dan Carpenter
  2015-02-25 13:46 ` Scott Feldman
@ 2015-02-25 13:55 ` Jiri Pirko
  2015-02-27 20:59 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Jiri Pirko @ 2015-02-25 13:55 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Scott Feldman, netdev, kernel-janitors

Wed, Feb 25, 2015 at 02:35:32PM CET, dan.carpenter@oracle.com wrote:
>Make sure kmalloc() succeeds.

Ough, nice catch. I see that the error path when rocker_probe_port fails
is also broken - I will send follow-up fix. Thanks!

>
>Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Acked-by: Jiri Pirko <jiri@resnulli.us>

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

* Re: [patch 1/2] rocker: add a check for NULL in rocker_probe_ports()
  2015-02-25 13:35 [patch 1/2] rocker: add a check for NULL in rocker_probe_ports() Dan Carpenter
  2015-02-25 13:46 ` Scott Feldman
  2015-02-25 13:55 ` Jiri Pirko
@ 2015-02-27 20:59 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2015-02-27 20:59 UTC (permalink / raw)
  To: dan.carpenter; +Cc: jiri, sfeldma, netdev, kernel-janitors

From: Dan Carpenter <dan.carpenter@oracle.com>
Date: Wed, 25 Feb 2015 16:35:32 +0300

> Make sure kmalloc() succeeds.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Applied.

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

end of thread, other threads:[~2015-02-27 20:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-25 13:35 [patch 1/2] rocker: add a check for NULL in rocker_probe_ports() Dan Carpenter
2015-02-25 13:46 ` Scott Feldman
2015-02-25 13:55 ` Jiri Pirko
2015-02-27 20:59 ` David Miller

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).