[PATCH] net: dsa: lan9303: correctly check return value of devm_gpiod_get_optional

2017-11-12 Thread Pan Bian
Function devm_gpiod_get_optional() returns an ERR_PTR on failure. Its return value should not be validated by a NULL check. Instead, use IS_ERR. Signed-off-by: Pan Bian <bianpan2...@163.com> --- drivers/net/dsa/lan9303-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff

[PATCH] net: hns: set correct return value

2017-10-30 Thread Pan Bian
is unexpected. Signed-off-by: Pan Bian <bianpan2...@163.com> --- drivers/net/ethernet/hisilicon/hns/hns_enet.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c b/drivers/net/ethernet/hisilicon/hns/hns_enet.c index 3652063..e

net: hns: set correct return value

2017-10-29 Thread Pan Bian
is unexpected. Signed-off-by: Pan Bian <bianpan2...@163.com> --- drivers/net/ethernet/hisilicon/hns/hns_enet.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c b/drivers/net/ethernet/hisilicon/hns/hns_enet.c index 3652063..e

net: lapbether: fix double free

2017-10-29 Thread Pan Bian
The function netdev_priv() returns the private data of the device. The memory to store the private data is allocated in alloc_netdev() and is released in netdev_free(). Calling kfree() on the return value of netdev_priv() after netdev_free() results in a double free bug. Signed-off-by: Pan Bian

xen/9pfs: check return value of xenbus_read correctly

2017-08-08 Thread Pan Bian
-off-by: Pan Bian <bianpan2...@163.com> --- net/9p/trans_xen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/9p/trans_xen.c b/net/9p/trans_xen.c index 6ad3e04..c548781 100644 --- a/net/9p/trans_xen.c +++ b/net/9p/trans_xen.c @@ -389,7 +389,7 @@ static int xen_9pfs_front

[PATCH net] team: fix memory leaks

2017-04-24 Thread Pan Bian
sages for options transfers") Signed-off-by: Pan Bian <bianpan2...@163.com> --- drivers/net/team/team.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c index f8c81f1..85c0124 100644 --- a/drivers/net/team/team.c +

[net 1/1] team: fix memory leaks

2017-04-24 Thread Pan Bian
sages for options transfers") Signed-off-by: Pan Bian <bianpan2...@163.com> --- drivers/net/team/team.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c index f8c81f1..85c0124 100644 --- a/drivers/net/team/team.c +

[PATCH 2/2] net: team: fix memory leak in team_nl_send_options_get

2017-04-24 Thread Pan Bian
emory leak") Signed-off-by: Pan Bian <bianpan2...@163.com> --- drivers/net/team/team.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c index dd3a2e9..85c0124 100644 --- a/drivers/net/team/team.c +++ b/drivers

[PATCH 1/2] net: team: fix memory leak in team_nl_send_port_list_get

2017-04-24 Thread Pan Bian
In function team_nl_send_port_list_get(), pointer skb keeps the return value of nlmsg_new(). When the call to genlmsg_put() fails, the memory is not freed. This will result in a memory leak bug. This patch fixes it. Fixes: fbd69cda90e7 ("team: fix memory leak") Signed-off-by: Pan Bian

[PATCH 1/1] rndis_wlan: add return value validation

2017-04-23 Thread Pan Bian
From: Pan Bian <bianpan2...@163.com> Function create_singlethread_workqueue() will return a NULL pointer if there is no enough memory, and its return value should be validated before using. However, in function rndis_wlan_bind(), its return value is not checked. This may cause NULL deref

[PATCH 1/1] cfg80211: add return value validation

2017-04-23 Thread Pan Bian
From: Pan Bian <bianpan2...@163.com> Function create_singlethread_workqueue() will return a NULL pointer if there is no enough memory, and its return value should be validated before using. However, in function rndis_wlan_bind(), its return value is not checked. This may cause NULL deref

[PATCH 1/1] libertas: check return value of alloc_workqueue

2017-04-23 Thread Pan Bian
From: Pan Bian <bianpan2...@163.com> Function alloc_workqueue() will return a NULL pointer if there is no enough memory, and its return value should be validated before using. However, in function if_spi_probe(), its return value is not checked. This may result in a NULL dereferen

[PATCH 1/1] qlcnic: fix unchecked return value

2017-04-23 Thread Pan Bian
From: Pan Bian <bianpan2...@163.com> Function pci_find_ext_capability() may return 0, which is an invalid address. In function qlcnic_sriov_virtid_fn(), its return value is used without validation. This may result in invalid memory access bugs. This patch fixes the bug. Signed-off-by: Pa

[PATCH 1/1] net: bcmgenet: fix incorrect return value checks

2017-04-23 Thread Pan Bian
From: Pan Bian <bianpan2...@163.com> Function platform_get_irq() will return a negative value on errors. However, in function bcmgenet_probe(), 0 is considered as a flag of error. This patch fixes the bug by checking whether the return value of platform_get_irq() is less than 0. Sign

[PATCH 1/1] wan: pc300too: abort path on failure

2017-04-23 Thread Pan Bian
From: Pan Bian <bianpan2...@163.com> In function pc300_pci_init_one(), on the ioremap error path, function pc300_pci_remove_one() is called to free the allocated memory. However, the path is not terminated, and the freed memory will be used later, resulting in use-after-free bugs. This path

[PATCH 2/2] team: fix memory leak

2017-04-23 Thread Pan Bian
In function team_nl_send_options_get(), pointer skb keeps the return value of function nlmsg_new(). When the call to genlmsg_put() fails, the control flow directly returns and does not free skb. This will result in a memory leak bug. This patch fixes it. Signed-off-by: Pan Bian <bianpan2...@

[PATCH 1/2] team: fix memory leak

2017-04-23 Thread Pan Bian
In function team_nl_send_port_list_get(), pointer skb keeps the return value of nlmsg_new(). When the call to genlmsg_put() fails, the memory is not freed. This will result in a memory leak bug. This patch fixes it. Signed-off-by: Pan Bian <bianpan2...@163.com> --- drivers/net/team/team

[PATCH 1/1] tipc: check return value of nlmsg_new

2017-04-23 Thread Pan Bian
-by: Pan Bian <bianpan2...@163.com> --- net/tipc/node.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/tipc/node.c b/net/tipc/node.c index 4512e83..568e48d 100644 --- a/net/tipc/node.c +++ b/net/tipc/node.c @@ -2098,6 +2098,8 @@ int tipc_nl_node_get_monitor(struct sk_buff *skb,

[PATCH 1/1] mt7601u: check return value of alloc_skb

2017-04-23 Thread Pan Bian
Function alloc_skb() will return a NULL pointer if there is no enough memory. However, in function mt7601u_mcu_msg_alloc(), its return value is not validated before it is used. This patch fixes it. Signed-off-by: Pan Bian <bianpan2...@163.com> --- drivers/net/wireless/mediatek/mt7601u/mcu.

[PATCH 1/1] openvswitch: check return value of nla_nest_start

2017-04-23 Thread Pan Bian
-off-by: Pan Bian <bianpan2...@163.com> --- net/openvswitch/datapath.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c index 9c62b63..34c0fbd 100644 --- a/net/openvswitch/datapath.c +++ b/net/openvswitch/data

[PATCH 1/1] lwtunnel: check return value of nla_nest_start

2017-04-23 Thread Pan Bian
Function nla_nest_start() may return a NULL pointer on error. However, in function lwtunnel_fill_encap(), the return value of nla_nest_start() is not validated before it is used. This patch checks the return value of nla_nest_start() against NULL. Signed-off-by: Pan Bian <bianpan2...@163.

[PATCH 1/1] orinoco: fix improper return value

2016-12-07 Thread Pan Bian
bug.cgi?id=188671 Signed-off-by: Pan Bian <bianpan2...@163.com> --- drivers/net/wireless/intersil/orinoco/wext.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/intersil/orinoco/wext.c b/drivers/net/wireless/intersil/orinoco/wext.c index 1d4dae4

[PATCH 1/1] net: qed: set error code on failure

2016-12-04 Thread Pan Bian
From: Pan Bian <bianpan2...@163.com> When calling dma_mapping_error(), the value of return variable rc is 0. And when the call returns an unexpected value, rc is not set to a negative errno. Thus, it will return 0 on the error path, and its callers cannot detect the bug. This patch fixes t

[PATCH 1/1 v2] net: bnx2x: fix improper return value

2016-12-04 Thread Pan Bian
From: Pan Bian <bianpan2...@163.com> Macro BNX2X_ALLOC_AND_SET(arr, lbl, func) calls kmalloc() to allocate memory, and jumps to label "lbl" if the allocation fails. Label "lbl" first cleans memory and then returns variable rc. Before calling the macro, the value of v

[PATCH 1/1 v2] isdn: hisax: set error code on failure

2016-12-04 Thread Pan Bian
From: Pan Bian <bianpan2...@163.com> In function hfc4s8s_probe(), the value of return variable err should be negative on failures. However, when the call to request_region() returns NULL, the value of err is 0. This patch fixes the bug, assigning "-EBUSY" to err on the path tha

[PATCH 1/1] net: bnx2x: fix improper return value

2016-12-04 Thread Pan Bian
From: Pan Bian <bianpan2...@163.com> Macro BNX2X_ALLOC_AND_SET(arr, lbl, func) calls kmalloc() to allocate memory, and jumps to label "lbl" if the allocation fails. Label "lbl" first cleans memory and then returns variable rc. Before calling the macro, the value of v

[PATCH 1/1] isdn: hisax: set error code on failure

2016-12-04 Thread Pan Bian
From: Pan Bian <bianpan2...@163.com> In function hfc4s8s_probe(), the value of return variable err should be negative on failures. However, when the call to request_region() returns NULL, the value of err is 0. This patch fixes the bug, assiging "-EBUSY" to err on the path tha

[PATCH 1/1] net: bnx2x: fix improper return value

2016-12-04 Thread Pan Bian
From: Pan Bian <bianpan2...@163.com> Marco BNX2X_ALLOC_AND_SET(arr, lbl, func) calls kmalloc() to allocate memory, and jumps to label "lbl" if the allocation fails. Label "lbl" first cleans memory and then returns variable rc. Before calling the macro, the value of v

[PATCH 1/1] net: ethernet: broadcom: fix improper return value

2016-12-03 Thread Pan Bian
From: Pan Bian <bianpan2...@163.com> Marco BNX2X_ALLOC_AND_SET(arr, lbl, func) calls kmalloc() to allocate memory, and jumps to label "lbl" if the allocation fails. Label "lbl" first cleans memory and then returns variable rc. Before calling the macro, the value of v

[PATCH 1/1] net: ethernet: qlogic: fix improper return value

2016-12-03 Thread Pan Bian
From: Pan Bian <bianpan2...@163.com> When the call to qlcnic_alloc_mbx_args() fails, returning variable "err" seems improper. With reference to the context, returing variable "config" may be better. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=189101 Signed-

[PATCH 1/1] net: ethernet: qlogic: set error code on failure

2016-12-03 Thread Pan Bian
From: Pan Bian <bianpan2...@163.com> When calling dma_mapping_error(), the value of return variable rc is 0. And when the call returns an unexpected value, rc is not set to a negative errno. Thus, it will return 0 on the error path, and its callers cannot detect the bug. This patch fixes t

[PATCH 1/1] atm: fix improper return value

2016-12-03 Thread Pan Bian
From: Pan Bian <bianpan2...@163.com> It returns variable "error" when ioremap_nocache() returns a NULL pointer. The value of "error" is 0 then, which will mislead the callers to believe that there is no error. This patch fixes the bug, returning "-ENOMEM". B

[PATCH 1/1] net: irda: set error code on failures

2016-12-03 Thread Pan Bian
From: Pan Bian <bianpan2...@163.com> When the calls to kzalloc() fail, the value of return variable ret may be 0. 0 means success in this context. This patch fixes the bug, assigning "-ENOMEM" to ret before calling kzalloc(). Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?i

[PATCH 1/1] isdn: hisax: set error code on failure

2016-12-03 Thread Pan Bian
From: Pan Bian <bianpan2...@163.com> In function hfc4s8s_probe(), the value of return variable err should be negative on failures. However, when the call to request_region() returns NULL, the value of err is 0. This patch fixes the bug, assiging "-ENOMEM" to err on the path tha

[PATCH 1/1] net: caif: remove ineffective check

2016-12-03 Thread Pan Bian
lla: https://bugzilla.kernel.org/show_bug.cgi?id=188751 Signed-off-by: Pan Bian <bianpan2...@163.com> --- net/caif/caif_socket.c | 5 + 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/net/caif/caif_socket.c b/net/caif/caif_socket.c index aa209b1..92cbbd2 100644 --- a/net/caif/caif_socket.

Re: [PATCH 1/1] net: caif: fix ineffective error check

2016-12-03 Thread Pan Bian
From: PanBian <bianpan2...@163.com> Hello Sergei, On Sat, Dec 03, 2016 at 04:17:51PM +0300, Sergei Shtylyov wrote: > Hello. > > On 12/3/2016 2:18 PM, Pan Bian wrote: > > >In function caif_sktinit_module(), the check of the return value of > >sock_register() seems

Re: [PATCH 1/1] net: ethernet: 3com: set error code on failures

2016-12-03 Thread Pan Bian
e view of callers of typhoon_init_one(). Thanks! Best regards, Pan On Sat, Dec 03, 2016 at 02:53:07PM +0100, Lino Sanfilippo wrote: > Hi, > > On 03.12.2016 14:24, Pan Bian wrote: > > From: Pan Bian <bianpan2...@163.com> > > > > In function typhoon_init_one(), returns

[PATCH 1/1] net: dcb: set error code on failures

2016-12-03 Thread Pan Bian
From: Pan Bian <bianpan2...@163.com> In function dcbnl_cee_fill(), returns the value of variable err on errors. However, on some error paths (e.g. nla put fails), its value may be 0. It may be better to explicitly set a negative errno to variable err before returning. Bugzilla:

[PATCH 1/1] net: ethernet: 3com: set error code on failures

2016-12-03 Thread Pan Bian
From: Pan Bian <bianpan2...@163.com> In function typhoon_init_one(), returns the value of variable err on errors. However, on some error paths, variable err is not set to a negative errno. This patch assigns "-EIO" to err on those paths. Signed-off-by: Pan Bian <bianpan2...@16

[PATCH 1/1] atm: lanai: set error code when ioremap fails

2016-12-03 Thread Pan Bian
?id=188791 Signed-off-by: Pan Bian <bianpan2...@163.com> --- drivers/atm/lanai.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c index ce43ae3..445505d 100644 --- a/drivers/atm/lanai.c +++ b/drivers/atm/lanai.c @@ -2143,6 +2143,7 @@ static in

[PATCH 1/1] net: caif: fix ineffective error check

2016-12-03 Thread Pan Bian
In function caif_sktinit_module(), the check of the return value of sock_register() seems ineffective. This patch fixes it. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188751 Signed-off-by: Pan Bian <bianpan2...@163.com> --- net/caif/caif_socket.c | 2 +- 1 file changed, 1 ins

[PATCH 1/1] net: bridge: set error code on failure

2016-12-03 Thread Pan Bian
Function br_sysfs_addbr() does not set error code when the call kobject_create_and_add() returns a NULL pointer. It may be better to return "-ENOMEM" when kobject_create_and_add() fails. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188781 Signed-off-by: Pan Bian <bianpa

[PATCH 1/1] net: usb: set error code when usb_alloc_urb fails

2016-12-03 Thread Pan Bian
o ret when usb_alloc_urb() returns a NULL pointer. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188771 Signed-off-by: Pan Bian <bianpan2...@163.com> --- drivers/net/usb/lan78xx.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx

[PATCH 1/1] net: wireless: marvell: fix improper return value

2016-12-03 Thread Pan Bian
stack memory to user sapce, resulting in stack information leak. To avoid the bug, this patch returns variable ret (which takes the return value of lbs_cmd_with_response()) instead of 0. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188451 Signed-off-by: Pan Bian <bianpan2...@163.

[PATCH 1/1] net: wireless: intersil: fix improper return value

2016-12-03 Thread Pan Bian
bug.cgi?id=188671 Signed-off-by: Pan Bian <bianpan2...@163.com> --- drivers/net/wireless/intersil/orinoco/wext.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/intersil/orinoco/wext.c b/drivers/net/wireless/intersil/orinoco/wext.c index 1d4dae4

[PATCH 1/1] net: wireless: intersil: fix improper return value

2016-12-03 Thread Pan Bian
bug.cgi?id=188671 Signed-off-by: Pan Bian <bianpan2...@163.com> --- drivers/net/wireless/intersil/orinoco/wext.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/intersil/orinoco/wext.c b/drivers/net/wireless/intersil/orinoco/wext.c index 1d4dae4

[PATCH 1/1] netdev: broadcom: propagate error code

2016-12-03 Thread Pan Bian
Function bnxt_hwrm_stat_ctx_alloc() always returns 0, even if the call to _hwrm_send_message() fails. It may be better to propagate the errors to the caller of bnxt_hwrm_stat_ctx_alloc(). Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188661 Signed-off-by: Pan Bian <bianpan2...@163.