Backports Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] backport: check for failure when allocating ops in genetlink
@ 2019-04-02 13:08 Luca Coelho
  0 siblings, 0 replies; only message in thread
From: Luca Coelho @ 2019-04-02 13:08 UTC (permalink / raw)
  To: backports; +Cc: Luca Coelho

From: Luca Coelho <luciano.coelho@intel.com>

We were not checking if the allocation failed in
backport_genl_register_family(), which could lead to NULL pointer
dereferences later.  Fix that.

Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
---
 backport/compat/backport-genetlink.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/backport/compat/backport-genetlink.c b/backport/compat/backport-genetlink.c
index 885f17568333..16971ec34e38 100644
--- a/backport/compat/backport-genetlink.c
+++ b/backport/compat/backport-genetlink.c
@@ -220,7 +220,11 @@ int backport_genl_register_family(struct genl_family *family)
 
 	/* we append one entry to the ops to find our family pointer ... */
 	ops = kzalloc(sizeof(*ops) * (family->n_ops + 1), GFP_KERNEL);
+	if (!ops)
+		return -ENOMEM;
+
 	memcpy(ops, family->ops, sizeof(*ops) * family->n_ops);
+
 	/*
 	 * Remove policy to skip validation as the struct nla_policy
 	 * memory layout isn't compatible with the old version
-- 
2.20.1

--
To unsubscribe from this list: send the line "unsubscribe backports" in

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-02 13:08 [PATCH] backport: check for failure when allocating ops in genetlink Luca Coelho

Backports Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/backports/0 backports/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 backports backports/ https://lore.kernel.org/backports \
		backports@vger.kernel.org backports@archiver.kernel.org
	public-inbox-index backports


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.backports


AGPL code for this site: git clone https://public-inbox.org/ public-inbox