Skip to contentSkip to conversation

dcb_doit: remove redundant skb check

PATCH In review Gaurav Singh 3 participants 5 messages Jun 21, 2020 – Jun 29, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dcb_doit: remove redundant skb check

Remove the redundant null check for skb.

---
 net/dcb/dcbnl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/dcb/dcbnl.c +1 -1
index d2a4553bcf39..84dde5a2066e 100644
@@ -1736,7 +1736,7 @@ static int dcb_doit(struct sk_buff *skb, struct nlmsghdr *nlh,
 	struct net_device *netdev;
 	struct dcbmsg *dcb = nlmsg_data(nlh);
 	struct nlattr *tb[DCB_ATTR_MAX + 1];
-	u32 portid = skb ? NETLINK_CB(skb).portid : 0;
+	u32 portid = NETLINK_CB(skb).portid;
 	int ret = -EINVAL;
 	struct sk_buff *reply_skb;
 	struct nlmsghdr *reply_nlh = NULL;
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 3 lines · On Sun, 21 Jun 2020 12:56:28 -0400 Gaurav Singh wrote:

Remove the redundant null check for skb.

Thanks for the patch, it looks correct, but could you describe your proof / reasoning based on which this change is correct?

Please post non-bug fixes like this with a [net-next] rather than [net] tag (https://www.kernel.org/doc/html/latest/networking/netdev-FAQ.html).

Quoted 13 lines
net/dcb/dcbnl.c +1 -1
index d2a4553bcf39..84dde5a2066e 100644
@@ -1736,7 +1736,7 @@ static int dcb_doit(struct sk_buff *skb, struct nlmsghdr *nlh,
 	struct net_device *netdev;
 	struct dcbmsg *dcb = nlmsg_data(nlh);
 	struct nlattr *tb[DCB_ATTR_MAX + 1];
-	u32 portid = skb ? NETLINK_CB(skb).portid : 0;
+	u32 portid = NETLINK_CB(skb).portid;
 	int ret = -EINVAL;
 	struct sk_buff *reply_skb;
 	struct nlmsghdr *reply_nlh = NULL;
#2 lore raw

PATCH 1/1 dcb_doit: remove redundant skb check

In reply to Gaurav Singh

skb cannot be NULL here since its already being accessed
before: sock_net(skb->sk). Remove the redundant null check.

---
 net/dcb/dcbnl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/dcb/dcbnl.c +1 -1
index d2a4553bcf39..84dde5a2066e 100644
@@ -1736,7 +1736,7 @@ static int dcb_doit(struct sk_buff *skb, struct nlmsghdr *nlh,
 	struct net_device *netdev;
 	struct dcbmsg *dcb = nlmsg_data(nlh);
 	struct nlattr *tb[DCB_ATTR_MAX + 1];
-	u32 portid = skb ? NETLINK_CB(skb).portid : 0;
+	u32 portid = NETLINK_CB(skb).portid;
 	int ret = -EINVAL;
 	struct sk_buff *reply_skb;
 	struct nlmsghdr *reply_nlh = NULL;
Signature · 1 line
2.17.1
#4 lore raw

PATCH 1/1 read_file: fix memory leak

In reply to Gaurav Singh

Free buf before returning to avoid memory leak.

---
 scripts/insert-sys-cert.c | 1 +
 1 file changed, 1 insertion(+)
scripts/insert-sys-cert.c +1 -0
index 8902836c2342..22d99a8faca9 100644
@@ -250,6 +250,7 @@ static char *read_file(char *file_name, int *size)
 	}
 	if (read(fd, buf, *size) != *size) {
 		perror("File read failed");
+		free(buf);
 		close(fd);
 		return NULL;
 	}
Signature · 1 line
2.17.1