linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: YueHaibing <yuehaibing@huawei.com>
To: <ast@kernel.org>, <daniel@iogearbox.net>
Cc: <linux-kernel@vger.kernel.org>, <netdev@vger.kernel.org>,
	YueHaibing <yuehaibing@huawei.com>
Subject: [PATCH] bpf: check NULL for sk_to_full_sk()
Date: Mon, 21 May 2018 15:55:58 +0800	[thread overview]
Message-ID: <20180521075558.11968-1-yuehaibing@huawei.com> (raw)

like commit df39a9f106d5 ("bpf: check NULL for sk_to_full_sk() return value"),
we should check sk_to_full_sk return value against NULL.

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 include/linux/bpf-cgroup.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/bpf-cgroup.h b/include/linux/bpf-cgroup.h
index 30d15e6..fd3fbeb 100644
--- a/include/linux/bpf-cgroup.h
+++ b/include/linux/bpf-cgroup.h
@@ -91,7 +91,7 @@ int __cgroup_bpf_check_dev_permission(short dev_type, u32 major, u32 minor,
 	int __ret = 0;							       \
 	if (cgroup_bpf_enabled && sk && sk == skb->sk) {		       \
 		typeof(sk) __sk = sk_to_full_sk(sk);			       \
-		if (sk_fullsock(__sk))					       \
+		if (__sk && sk_fullsock(__sk))				       \
 			__ret = __cgroup_bpf_run_filter_skb(__sk, skb,	       \
 						      BPF_CGROUP_INET_EGRESS); \
 	}								       \
-- 
2.7.0

             reply	other threads:[~2018-05-21  7:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-21  7:55 YueHaibing [this message]
2018-05-21 15:17 ` [PATCH] bpf: check NULL for sk_to_full_sk() Eric Dumazet
2018-05-22  3:29   ` YueHaibing

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=20180521075558.11968-1-yuehaibing@huawei.com \
    --to=yuehaibing@huawei.com \
    --cc=ast@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@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).