mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] [net] dcb_doit: remove redundant skb check
@ 2020-06-21 16:56 Gaurav Singh
  2020-06-22 19:35 ` Jakub Kicinski
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Gaurav Singh @ 2020-06-21 16:56 UTC (permalink / raw)
  To: gaurav1086, David S. Miller, Jakub Kicinski,
	open list:NETWORKING [GENERAL],
	open list

Remove the redundant null check for skb.

Signed-off-by: Gaurav Singh <gaurav1086@gmail.com>
---
 net/dcb/dcbnl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c
index d2a4553bcf39..84dde5a2066e 100644
--- a/net/dcb/dcbnl.c
+++ b/net/dcb/dcbnl.c
@@ -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.17.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] [net] dcb_doit: remove redundant skb check
  2020-06-21 16:56 [PATCH] [net] dcb_doit: remove redundant skb check Gaurav Singh
@ 2020-06-22 19:35 ` Jakub Kicinski
  2020-06-23  2:50 ` Gaurav Singh
  2020-06-29  1:21 ` [PATCH] [scripts] read_file: fix memory leak Gaurav Singh
  2 siblings, 0 replies; 5+ messages in thread
From: Jakub Kicinski @ 2020-06-22 19:35 UTC (permalink / raw)
  To: Gaurav Singh; +Cc: David S. Miller, open list:NETWORKING [GENERAL], open list

On Sun, 21 Jun 2020 12:56:28 -0400 Gaurav Singh wrote:
> Remove the redundant null check for skb.
> 
> Signed-off-by: Gaurav Singh <gaurav1086@gmail.com>

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).

> diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c
> index d2a4553bcf39..84dde5a2066e 100644
> --- a/net/dcb/dcbnl.c
> +++ b/net/dcb/dcbnl.c
> @@ -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;


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] [net] dcb_doit: remove redundant skb check
  2020-06-21 16:56 [PATCH] [net] dcb_doit: remove redundant skb check Gaurav Singh
  2020-06-22 19:35 ` Jakub Kicinski
@ 2020-06-23  2:50 ` Gaurav Singh
  2020-06-24  3:27   ` David Miller
  2020-06-29  1:21 ` [PATCH] [scripts] read_file: fix memory leak Gaurav Singh
  2 siblings, 1 reply; 5+ messages in thread
From: Gaurav Singh @ 2020-06-23  2:50 UTC (permalink / raw)
  To: gaurav1086, David S. Miller, Jakub Kicinski,
	open list:NETWORKING [GENERAL],
	open list

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

Signed-off-by: Gaurav Singh <gaurav1086@gmail.com>
---
 net/dcb/dcbnl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c
index d2a4553bcf39..84dde5a2066e 100644
--- a/net/dcb/dcbnl.c
+++ b/net/dcb/dcbnl.c
@@ -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.17.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] [net] dcb_doit: remove redundant skb check
  2020-06-23  2:50 ` Gaurav Singh
@ 2020-06-24  3:27   ` David Miller
  0 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2020-06-24  3:27 UTC (permalink / raw)
  To: gaurav1086; +Cc: kuba, netdev, linux-kernel

From: Gaurav Singh <gaurav1086@gmail.com>
Date: Mon, 22 Jun 2020 22:50:39 -0400

> skb cannot be NULL here since its already being accessed
> before: sock_net(skb->sk). Remove the redundant null check.
> 
> Signed-off-by: Gaurav Singh <gaurav1086@gmail.com>

Applied.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] [scripts] read_file: fix memory leak
  2020-06-21 16:56 [PATCH] [net] dcb_doit: remove redundant skb check Gaurav Singh
  2020-06-22 19:35 ` Jakub Kicinski
  2020-06-23  2:50 ` Gaurav Singh
@ 2020-06-29  1:21 ` Gaurav Singh
  2 siblings, 0 replies; 5+ messages in thread
From: Gaurav Singh @ 2020-06-29  1:21 UTC (permalink / raw)
  To: gaurav1086, open list

Free buf before returning to avoid memory leak.

Signed-off-by: Gaurav Singh <gaurav1086@gmail.com>
---
 scripts/insert-sys-cert.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/scripts/insert-sys-cert.c b/scripts/insert-sys-cert.c
index 8902836c2342..22d99a8faca9 100644
--- a/scripts/insert-sys-cert.c
+++ b/scripts/insert-sys-cert.c
@@ -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;
 	}
-- 
2.17.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-06-29  1:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-21 16:56 [PATCH] [net] dcb_doit: remove redundant skb check Gaurav Singh
2020-06-22 19:35 ` Jakub Kicinski
2020-06-23  2:50 ` Gaurav Singh
2020-06-24  3:27   ` David Miller
2020-06-29  1:21 ` [PATCH] [scripts] read_file: fix memory leak Gaurav Singh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®