[ethtool] 09/20: ethtool: avoid NULL pointer dereference in do_permaddr

debian-kernel at lists.debian.org debian-kernel at lists.debian.org
Mon Oct 17 04:09:56 UTC 2016


This is an automated email from the git hooks/post-receive script.

benh pushed a commit to branch master
in repository ethtool.

commit d70e1ebc02dea8082d605c96525e966305c792e4
Author: John W. Linville <linville at tuxdriver.com>
Date:   Thu Sep 29 14:05:41 2016 -0400

    ethtool: avoid NULL pointer dereference in do_permaddr
    
    Coverity issue: 1363118
    Fixes: fef1c4a19703 ("ethtool: add get permanent address option")
    
    Signed-off-by: John W. Linville <linville at tuxdriver.com>
    Reviewed-by: Greg Rose <grose at lightfleet.com>
---
 ethtool.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/ethtool.c b/ethtool.c
index 6287b55..aa3ef5e 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -3941,6 +3941,11 @@ static int do_permaddr(struct cmd_context *ctx)
 	struct ethtool_perm_addr *epaddr;
 
 	epaddr = malloc(sizeof(struct ethtool_perm_addr) + MAX_ADDR_LEN);
+	if (!epaddr) {
+		perror("Cannot allocate memory for operation");
+		return 1;
+	}
+
 	epaddr->cmd = ETHTOOL_GPERMADDR;
 	epaddr->size = MAX_ADDR_LEN;
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/kernel/ethtool.git



More information about the Kernel-svn-changes mailing list