Skip to content

Commit d717e4c

Browse files
committed
Merge tag 'net-5.18-rc0' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
Pull networking fixes from Jakub Kicinski: "Including fixes from netfilter. Current release - regressions: - llc: only change llc->dev when bind() succeeds, fix null-deref Current release - new code bugs: - smc: fix a memory leak in smc_sysctl_net_exit() - dsa: realtek: make interface drivers depend on OF Previous releases - regressions: - sched: act_ct: fix ref leak when switching zones Previous releases - always broken: - netfilter: egress: report interface as outgoing - vsock/virtio: enable VQs early on probe and finish the setup before using them Misc: - memcg: enable accounting for nft objects" * tag 'net-5.18-rc0' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (39 commits) Revert "selftests: net: Add tls config dependency for tls selftests" net/smc: Send out the remaining data in sndbuf before close net: move net_unlink_todo() out of the header net: dsa: bcm_sf2_cfp: fix an incorrect NULL check on list iterator net: bnxt_ptp: fix compilation error selftests: net: Add tls config dependency for tls selftests memcg: enable accounting for nft objects net/sched: act_ct: fix ref leak when switching zones net/smc: fix a memory leak in smc_sysctl_net_exit() selftests: tls: skip cmsg_to_pipe tests with TLS=n octeontx2-af: initialize action variable net: sparx5: switchdev: fix possible NULL pointer dereference net/x25: Fix null-ptr-deref caused by x25_disconnect qlcnic: dcb: default to returning -EOPNOTSUPP net: sparx5: depends on PTP_1588_CLOCK_OPTIONAL net: hns3: fix phy can not link up when autoneg off and reset net: hns3: add NULL pointer check for hns3_set/get_ringparam() net: hns3: add netdev reset check for hns3_set_tunable() net: hns3: clean residual vf config after disable sriov net: hns3: add max order judgement for tx spare buffer ...
2 parents cffb2b7 + 20695e9 commit d717e4c

File tree

38 files changed

+464
-194
lines changed

38 files changed

+464
-194
lines changed

drivers/net/dsa/bcm_sf2_cfp.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -567,14 +567,14 @@ static void bcm_sf2_cfp_slice_ipv6(struct bcm_sf2_priv *priv,
567567
static struct cfp_rule *bcm_sf2_cfp_rule_find(struct bcm_sf2_priv *priv,
568568
int port, u32 location)
569569
{
570-
struct cfp_rule *rule = NULL;
570+
struct cfp_rule *rule;
571571

572572
list_for_each_entry(rule, &priv->cfp.rules_list, next) {
573573
if (rule->port == port && rule->fs.location == location)
574-
break;
574+
return rule;
575575
}
576576

577-
return rule;
577+
return NULL;
578578
}
579579

580580
static int bcm_sf2_cfp_rule_cmp(struct bcm_sf2_priv *priv, int port,

drivers/net/dsa/realtek/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ menuconfig NET_DSA_REALTEK
1212
config NET_DSA_REALTEK_MDIO
1313
tristate "Realtek MDIO connected switch driver"
1414
depends on NET_DSA_REALTEK
15+
depends on OF
1516
help
1617
Select to enable support for registering switches configured
1718
through MDIO.
1819

1920
config NET_DSA_REALTEK_SMI
2021
tristate "Realtek SMI connected switch driver"
2122
depends on NET_DSA_REALTEK
23+
depends on OF
2224
help
2325
Select to enable support for registering switches connected
2426
through SMI.

drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,14 +382,16 @@ static int bnxt_ptp_enable(struct ptp_clock_info *ptp_info,
382382
struct bnxt_ptp_cfg *ptp = container_of(ptp_info, struct bnxt_ptp_cfg,
383383
ptp_info);
384384
struct bnxt *bp = ptp->bp;
385-
u8 pin_id;
385+
int pin_id;
386386
int rc;
387387

388388
switch (rq->type) {
389389
case PTP_CLK_REQ_EXTTS:
390390
/* Configure an External PPS IN */
391391
pin_id = ptp_find_pin(ptp->ptp_clock, PTP_PF_EXTTS,
392392
rq->extts.index);
393+
if (!TSIO_PIN_VALID(pin_id))
394+
return -EOPNOTSUPP;
393395
if (!on)
394396
break;
395397
rc = bnxt_ptp_cfg_pin(bp, pin_id, BNXT_PPS_PIN_PPS_IN);
@@ -403,6 +405,8 @@ static int bnxt_ptp_enable(struct ptp_clock_info *ptp_info,
403405
/* Configure a Periodic PPS OUT */
404406
pin_id = ptp_find_pin(ptp->ptp_clock, PTP_PF_PEROUT,
405407
rq->perout.index);
408+
if (!TSIO_PIN_VALID(pin_id))
409+
return -EOPNOTSUPP;
406410
if (!on)
407411
break;
408412

drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ struct pps_pin {
3131
u8 state;
3232
};
3333

34-
#define TSIO_PIN_VALID(pin) ((pin) < (BNXT_MAX_TSIO_PINS))
34+
#define TSIO_PIN_VALID(pin) ((pin) >= 0 && (pin) < (BNXT_MAX_TSIO_PINS))
3535

3636
#define EVENT_DATA2_PPS_EVENT_TYPE(data2) \
3737
((data2) & ASYNC_EVENT_CMPL_PPS_TIMESTAMP_EVENT_DATA2_EVENT_TYPE)

drivers/net/ethernet/freescale/enetc/enetc_ethtool.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,10 @@ static int enetc_get_ts_info(struct net_device *ndev,
674674
#ifdef CONFIG_FSL_ENETC_PTP_CLOCK
675675
info->so_timestamping = SOF_TIMESTAMPING_TX_HARDWARE |
676676
SOF_TIMESTAMPING_RX_HARDWARE |
677-
SOF_TIMESTAMPING_RAW_HARDWARE;
677+
SOF_TIMESTAMPING_RAW_HARDWARE |
678+
SOF_TIMESTAMPING_TX_SOFTWARE |
679+
SOF_TIMESTAMPING_RX_SOFTWARE |
680+
SOF_TIMESTAMPING_SOFTWARE;
678681

679682
info->tx_types = (1 << HWTSTAMP_TX_OFF) |
680683
(1 << HWTSTAMP_TX_ON) |

drivers/net/ethernet/hisilicon/hns3/hnae3.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,8 @@ struct hnae3_ae_dev {
537537
* Get 1588 rx hwstamp
538538
* get_ts_info
539539
* Get phc info
540+
* clean_vf_config
541+
* Clean residual vf info after disable sriov
540542
*/
541543
struct hnae3_ae_ops {
542544
int (*init_ae_dev)(struct hnae3_ae_dev *ae_dev);
@@ -730,6 +732,7 @@ struct hnae3_ae_ops {
730732
struct ethtool_ts_info *info);
731733
int (*get_link_diagnosis_info)(struct hnae3_handle *handle,
732734
u32 *status_code);
735+
void (*clean_vf_config)(struct hnae3_ae_dev *ae_dev, int num_vfs);
733736
};
734737

735738
struct hnae3_dcb_ops {

drivers/net/ethernet/hisilicon/hns3/hns3_enet.c

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,46 +1028,56 @@ static bool hns3_can_use_tx_sgl(struct hns3_enet_ring *ring,
10281028

10291029
static void hns3_init_tx_spare_buffer(struct hns3_enet_ring *ring)
10301030
{
1031+
u32 alloc_size = ring->tqp->handle->kinfo.tx_spare_buf_size;
10311032
struct hns3_tx_spare *tx_spare;
10321033
struct page *page;
1033-
u32 alloc_size;
10341034
dma_addr_t dma;
10351035
int order;
10361036

1037-
alloc_size = ring->tqp->handle->kinfo.tx_spare_buf_size;
10381037
if (!alloc_size)
10391038
return;
10401039

10411040
order = get_order(alloc_size);
1041+
if (order >= MAX_ORDER) {
1042+
if (net_ratelimit())
1043+
dev_warn(ring_to_dev(ring), "failed to allocate tx spare buffer, exceed to max order\n");
1044+
return;
1045+
}
1046+
10421047
tx_spare = devm_kzalloc(ring_to_dev(ring), sizeof(*tx_spare),
10431048
GFP_KERNEL);
10441049
if (!tx_spare) {
10451050
/* The driver still work without the tx spare buffer */
10461051
dev_warn(ring_to_dev(ring), "failed to allocate hns3_tx_spare\n");
1047-
return;
1052+
goto devm_kzalloc_error;
10481053
}
10491054

10501055
page = alloc_pages_node(dev_to_node(ring_to_dev(ring)),
10511056
GFP_KERNEL, order);
10521057
if (!page) {
10531058
dev_warn(ring_to_dev(ring), "failed to allocate tx spare pages\n");
1054-
devm_kfree(ring_to_dev(ring), tx_spare);
1055-
return;
1059+
goto alloc_pages_error;
10561060
}
10571061

10581062
dma = dma_map_page(ring_to_dev(ring), page, 0,
10591063
PAGE_SIZE << order, DMA_TO_DEVICE);
10601064
if (dma_mapping_error(ring_to_dev(ring), dma)) {
10611065
dev_warn(ring_to_dev(ring), "failed to map pages for tx spare\n");
1062-
put_page(page);
1063-
devm_kfree(ring_to_dev(ring), tx_spare);
1064-
return;
1066+
goto dma_mapping_error;
10651067
}
10661068

10671069
tx_spare->dma = dma;
10681070
tx_spare->buf = page_address(page);
10691071
tx_spare->len = PAGE_SIZE << order;
10701072
ring->tx_spare = tx_spare;
1073+
return;
1074+
1075+
dma_mapping_error:
1076+
put_page(page);
1077+
alloc_pages_error:
1078+
devm_kfree(ring_to_dev(ring), tx_spare);
1079+
devm_kzalloc_error:
1080+
ring->tqp->handle->kinfo.tx_spare_buf_size = 0;
10711081
}
10721082

10731083
/* Use hns3_tx_spare_space() to make sure there is enough buffer
@@ -3050,6 +3060,21 @@ static int hns3_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
30503060
return ret;
30513061
}
30523062

3063+
/**
3064+
* hns3_clean_vf_config
3065+
* @pdev: pointer to a pci_dev structure
3066+
* @num_vfs: number of VFs allocated
3067+
*
3068+
* Clean residual vf config after disable sriov
3069+
**/
3070+
static void hns3_clean_vf_config(struct pci_dev *pdev, int num_vfs)
3071+
{
3072+
struct hnae3_ae_dev *ae_dev = pci_get_drvdata(pdev);
3073+
3074+
if (ae_dev->ops->clean_vf_config)
3075+
ae_dev->ops->clean_vf_config(ae_dev, num_vfs);
3076+
}
3077+
30533078
/* hns3_remove - Device removal routine
30543079
* @pdev: PCI device information struct
30553080
*/
@@ -3088,7 +3113,10 @@ static int hns3_pci_sriov_configure(struct pci_dev *pdev, int num_vfs)
30883113
else
30893114
return num_vfs;
30903115
} else if (!pci_vfs_assigned(pdev)) {
3116+
int num_vfs_pre = pci_num_vf(pdev);
3117+
30913118
pci_disable_sriov(pdev);
3119+
hns3_clean_vf_config(pdev, num_vfs_pre);
30923120
} else {
30933121
dev_warn(&pdev->dev,
30943122
"Unable to free VFs because some are assigned to VMs.\n");

drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -653,8 +653,8 @@ static void hns3_get_ringparam(struct net_device *netdev,
653653
struct hnae3_handle *h = priv->ae_handle;
654654
int rx_queue_index = h->kinfo.num_tqps;
655655

656-
if (hns3_nic_resetting(netdev)) {
657-
netdev_err(netdev, "dev resetting!");
656+
if (hns3_nic_resetting(netdev) || !priv->ring) {
657+
netdev_err(netdev, "failed to get ringparam value, due to dev resetting or uninited\n");
658658
return;
659659
}
660660

@@ -1074,8 +1074,14 @@ static int hns3_check_ringparam(struct net_device *ndev,
10741074
{
10751075
#define RX_BUF_LEN_2K 2048
10761076
#define RX_BUF_LEN_4K 4096
1077-
if (hns3_nic_resetting(ndev))
1077+
1078+
struct hns3_nic_priv *priv = netdev_priv(ndev);
1079+
1080+
if (hns3_nic_resetting(ndev) || !priv->ring) {
1081+
netdev_err(ndev, "failed to set ringparam value, due to dev resetting or uninited\n");
10781082
return -EBUSY;
1083+
}
1084+
10791085

10801086
if (param->rx_mini_pending || param->rx_jumbo_pending)
10811087
return -EINVAL;
@@ -1766,9 +1772,6 @@ static int hns3_set_tx_spare_buf_size(struct net_device *netdev,
17661772
struct hnae3_handle *h = priv->ae_handle;
17671773
int ret;
17681774

1769-
if (hns3_nic_resetting(netdev))
1770-
return -EBUSY;
1771-
17721775
h->kinfo.tx_spare_buf_size = data;
17731776

17741777
ret = hns3_reset_notify(h, HNAE3_DOWN_CLIENT);
@@ -1799,6 +1802,11 @@ static int hns3_set_tunable(struct net_device *netdev,
17991802
struct hnae3_handle *h = priv->ae_handle;
18001803
int i, ret = 0;
18011804

1805+
if (hns3_nic_resetting(netdev) || !priv->ring) {
1806+
netdev_err(netdev, "failed to set tunable value, dev resetting!");
1807+
return -EBUSY;
1808+
}
1809+
18021810
switch (tuna->id) {
18031811
case ETHTOOL_TX_COPYBREAK:
18041812
priv->tx_copybreak = *(u32 *)data;
@@ -1818,7 +1826,8 @@ static int hns3_set_tunable(struct net_device *netdev,
18181826
old_tx_spare_buf_size = h->kinfo.tx_spare_buf_size;
18191827
new_tx_spare_buf_size = *(u32 *)data;
18201828
ret = hns3_set_tx_spare_buf_size(netdev, new_tx_spare_buf_size);
1821-
if (ret) {
1829+
if (ret ||
1830+
(!priv->ring->tx_spare && new_tx_spare_buf_size != 0)) {
18221831
int ret1;
18231832

18241833
netdev_warn(netdev,

0 commit comments

Comments
 (0)