stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: <gregkh@linuxfoundation.org>
To: mkl@pengutronix.de, gregkh@linuxfoundation.org, socketcan@hartkopp.net
Cc: <stable@vger.kernel.org>, <stable-commits@vger.kernel.org>
Subject: Patch "can: af_can: can_pernet_init(): add missing error handling for kzalloc returning NULL" has been added to the 4.13-stable tree
Date: Mon, 23 Oct 2017 14:56:31 +0200	[thread overview]
Message-ID: <150876339191244@kroah.com> (raw)


This is a note to let you know that I've just added the patch titled

    can: af_can: can_pernet_init(): add missing error handling for kzalloc returning NULL

to the 4.13-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     can-af_can-can_pernet_init-add-missing-error-handling-for-kzalloc-returning-null.patch
and it can be found in the queue-4.13 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@vger.kernel.org> know about it.


>From 5a606223c6b5b7560da253ed52e62c67fa18e29b Mon Sep 17 00:00:00 2001
From: Marc Kleine-Budde <mkl@pengutronix.de>
Date: Sat, 29 Jul 2017 11:51:01 +0200
Subject: can: af_can: can_pernet_init(): add missing error handling for kzalloc returning NULL

From: Marc Kleine-Budde <mkl@pengutronix.de>

commit 5a606223c6b5b7560da253ed52e62c67fa18e29b upstream.

This patch adds the missing check and error handling for out-of-memory
situations, when kzalloc cannot allocate memory.

Fixes: cb5635a36776 ("can: complete initial namespace support")
Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 net/can/af_can.c |   14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

--- a/net/can/af_can.c
+++ b/net/can/af_can.c
@@ -875,9 +875,14 @@ static int can_pernet_init(struct net *n
 	spin_lock_init(&net->can.can_rcvlists_lock);
 	net->can.can_rx_alldev_list =
 		kzalloc(sizeof(struct dev_rcv_lists), GFP_KERNEL);
-
+	if (!net->can.can_rx_alldev_list)
+		goto out;
 	net->can.can_stats = kzalloc(sizeof(struct s_stats), GFP_KERNEL);
+	if (!net->can.can_stats)
+		goto out_free_alldev_list;
 	net->can.can_pstats = kzalloc(sizeof(struct s_pstats), GFP_KERNEL);
+	if (!net->can.can_pstats)
+		goto out_free_can_stats;
 
 	if (IS_ENABLED(CONFIG_PROC_FS)) {
 		/* the statistics are updated every second (timer triggered) */
@@ -892,6 +897,13 @@ static int can_pernet_init(struct net *n
 	}
 
 	return 0;
+
+ out_free_can_stats:
+	kfree(net->can.can_stats);
+ out_free_alldev_list:
+	kfree(net->can.can_rx_alldev_list);
+ out:
+	return -ENOMEM;
 }
 
 static void can_pernet_exit(struct net *net)


Patches currently in stable-queue which might be from mkl@pengutronix.de are

queue-4.13/can-flexcan-rename-legacy-error-state-quirk.patch
queue-4.13/can-af_can-can_pernet_init-add-missing-error-handling-for-kzalloc-returning-null.patch
queue-4.13/can-flexcan-implement-error-passive-state-quirk.patch
queue-4.13/can-flexcan-fix-i.mx28-state-transition-issue.patch
queue-4.13/can-flexcan-fix-state-transition-regression.patch
queue-4.13/can-flexcan-fix-i.mx6-state-transition-issue.patch
queue-4.13/can-flexcan-fix-p1010-state-transition-issue.patch
queue-4.13/can-esd_usb2-fix-can_dlc-value-for-received-rtr-frames.patch
queue-4.13/can-gs_usb-fix-busy-loop-if-no-more-tx-context-is-available.patch

                 reply	other threads:[~2017-10-23 12:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=150876339191244@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=mkl@pengutronix.de \
    --cc=socketcan@hartkopp.net \
    --cc=stable-commits@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /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: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).