git: 89204d9dcbe2 - main - bpf: Prefer the boolean form when calling bpf_peers_present()

2024-06-07 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=89204d9dcbe28558fae65936a0e93f44d926b88f

commit 89204d9dcbe28558fae65936a0e93f44d926b88f
Author: Zhenlei Huang 
AuthorDate: 2024-06-07 15:06:07 +
Commit: Zhenlei Huang 
CommitDate: 2024-06-07 15:06:07 +

bpf: Prefer the boolean form when calling bpf_peers_present()

No functional change intended.

Reviewed by:markj, kp, #network
MFC with:   8f31b879ecaf
Differential Revision:  https://reviews.freebsd.org/D45509
---
 sys/net/bpf.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/sys/net/bpf.c b/sys/net/bpf.c
index 1078c57dfee2..7983337064be 100644
--- a/sys/net/bpf.c
+++ b/sys/net/bpf.c
@@ -2880,9 +2880,7 @@ bpfdetach(struct ifnet *ifp)
 bool
 bpf_peers_present_if(struct ifnet *ifp)
 {
-   struct bpf_if *bp = ifp->if_bpf;
-
-   return (bpf_peers_present(bp) > 0);
+   return (bpf_peers_present(ifp->if_bpf));
 }
 
 /*



git: 0dfd11abc4bd - main - bpf: Make bpf_peers_present a boolean inline function

2024-06-07 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=0dfd11abc4bd0dcb96a6d287cc4e52e8f59b64c1

commit 0dfd11abc4bd0dcb96a6d287cc4e52e8f59b64c1
Author: Zhenlei Huang 
AuthorDate: 2024-06-07 15:06:08 +
Commit: Zhenlei Huang 
CommitDate: 2024-06-07 15:06:08 +

bpf: Make bpf_peers_present a boolean inline function

This function was introduced in commit [1] and is actually used as a
boolean function although it was not defined as so.

No functional change intended.

1. 16d878cc99ef Fix the following bpf(4) race condition which can result in 
a panic

Reviewed by:markj, kp, #network
MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45509
---
 sys/net/bpf.h | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/sys/net/bpf.h b/sys/net/bpf.h
index 0fd7c4105b30..e44a7cd2359d 100644
--- a/sys/net/bpf.h
+++ b/sys/net/bpf.h
@@ -433,15 +433,13 @@ intbpf_get_bp_params(struct bpf_if *, u_int *, 
u_int *);
 voidbpfilterattach(int);
 u_int   bpf_filter(const struct bpf_insn *, u_char *, u_int, u_int);
 
-static __inline int
+static __inline bool
 bpf_peers_present(struct bpf_if *bpf)
 {
struct bpf_if_ext *ext;
 
ext = (struct bpf_if_ext *)bpf;
-   if (!CK_LIST_EMPTY(&ext->bif_dlist))
-   return (1);
-   return (0);
+   return (!CK_LIST_EMPTY(&ext->bif_dlist));
 }
 
 #defineBPF_TAP(_ifp,_pkt,_pktlen)  \



git: 23f4131ad685 - main - sys/sysctl.h: Fix wrong assertion with multiple access flags

2024-06-07 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=23f4131ad685debef98566351cb9f0e0a5903903

commit 23f4131ad685debef98566351cb9f0e0a5903903
Author: Zhenlei Huang 
AuthorDate: 2024-06-08 03:21:11 +
Commit: Zhenlei Huang 
CommitDate: 2024-06-08 03:21:11 +

sys/sysctl.h: Fix wrong assertion with multiple access flags

With multiple flags passed in, e.g., CTLFLAG_RD | CTLFLAG_CAPRD, due to
the precedence rules, this will result in false positive assertion. Fix
that by surrounding the replacement lists with parentheses.

Reviewed by:imp, erj
Fixes:  10a1e981d411 iflib: mark isc_driver_version as constant
MFC after:  3 days
Differential Revision:  https://reviews.freebsd.org/D45531
---
 sys/sys/sysctl.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h
index d80e0fbbe2e4..7b27cb307e0c 100644
--- a/sys/sys/sysctl.h
+++ b/sys/sys/sysctl.h
@@ -393,14 +393,14 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);
 #defineSYSCTL_CONST_STRING(parent, nbr, name, access, arg, descr)  
\
SYSCTL_OID(parent, nbr, name, CTLTYPE_STRING | CTLFLAG_MPSAFE | 
(access),\
__DECONST(char *, arg), 0, sysctl_handle_string, "A", descr); \
-   CTASSERT(!(access & CTLFLAG_WR));   \
+   CTASSERT(!((access) & CTLFLAG_WR)); \
CTASSERT(((access) & CTLTYPE) == 0 ||   \
((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_STRING)
 
 #defineSYSCTL_ADD_CONST_STRING(ctx, parent, nbr, name, access, arg, 
descr) \
 ({ \
char *__arg = __DECONST(char *, arg);   \
-   CTASSERT(!(access & CTLFLAG_WR));   \
+   CTASSERT(!((access) & CTLFLAG_WR)); \
CTASSERT(((access) & CTLTYPE) == 0 ||   \
((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_STRING);  \
sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_STRING | \



git: ebc2bab04823 - main - pflog: Correctly check if bpf peers are present

2024-06-08 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=ebc2bab04823c24c524f913457d6b88dc7ea9fac

commit ebc2bab04823c24c524f913457d6b88dc7ea9fac
Author: Zhenlei Huang 
AuthorDate: 2024-06-09 01:05:22 +
Commit: Zhenlei Huang 
CommitDate: 2024-06-09 01:05:22 +

pflog: Correctly check if bpf peers are present

On creating the pflog(4) interface, pflog_clone_create() does an
unconditional bpfattach(). Use bpf_peers_present() which was introduced
in commit 16d878cc99ef [1] to check the presence of bpf peers.

This will save a little CPU cycles when no bpf peers present. There
should be no functional change.

1. 16d878cc99ef Fix the following bpf(4) race condition which can result in 
a panic

Reviewed by:kp
MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45532
---
 sys/netpfil/pf/if_pflog.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/sys/netpfil/pf/if_pflog.c b/sys/netpfil/pf/if_pflog.c
index 7ac337a84c5d..1e73d5f51851 100644
--- a/sys/netpfil/pf/if_pflog.c
+++ b/sys/netpfil/pf/if_pflog.c
@@ -223,9 +223,10 @@ pflog_packet(struct pfi_kkif *kif, struct mbuf *m, 
sa_family_t af,
struct pfloghdr hdr;
 
if (kif == NULL || m == NULL || rm == NULL || pd == NULL)
-   return ( 1);
+   return (1);
 
-   if ((ifn = V_pflogifs[rm->logif]) == NULL || !ifn->if_bpf)
+   ifn = V_pflogifs[rm->logif];
+   if (ifn == NULL || !bpf_peers_present(ifn->if_bpf))
return (0);
 
bzero(&hdr, sizeof(hdr));
@@ -274,7 +275,7 @@ pflog_packet(struct pfi_kkif *kif, struct mbuf *m, 
sa_family_t af,
 
if_inc_counter(ifn, IFCOUNTER_OPACKETS, 1);
if_inc_counter(ifn, IFCOUNTER_OBYTES, m->m_pkthdr.len);
-   BPF_MTAP2(ifn, &hdr, PFLOG_HDRLEN, m);
+   bpf_mtap2(ifn->if_bpf, &hdr, PFLOG_HDRLEN, m);
 
return (0);
 }



git: 2671bde99295 - main - pfsync: Correctly check if bpf peers are present

2024-06-08 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=2671bde99295d9e01d10316d0f3fb8b6d21f0f4d

commit 2671bde99295d9e01d10316d0f3fb8b6d21f0f4d
Author: Zhenlei Huang 
AuthorDate: 2024-06-09 01:05:22 +
Commit: Zhenlei Huang 
CommitDate: 2024-06-09 01:05:22 +

pfsync: Correctly check if bpf peers are present

On creating the pfsync(4) interface, pfsync_clone_create() does an
unconditional bpfattach(). Use bpf_peers_present() which was introduced
in commit 16d878cc99ef [1] to check the presence of bpf peers.

This will save a little CPU cycles and memory usage when the
synchronisation interface is not configured and there is no bpf peers
present. There should be no functional change.

1. 16d878cc99ef Fix the following bpf(4) race condition which can result in 
a panic

Reviewed by:kp
MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45533
---
 sys/netpfil/pf/if_pfsync.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sys/netpfil/pf/if_pfsync.c b/sys/netpfil/pf/if_pfsync.c
index c22a6a5982a9..80d6fddc709c 100644
--- a/sys/netpfil/pf/if_pfsync.c
+++ b/sys/netpfil/pf/if_pfsync.c
@@ -1796,7 +1796,7 @@ pfsync_sendout(int schedswi, int c)
("%s: sc_len %zu", __func__, b->b_len));
PFSYNC_BUCKET_LOCK_ASSERT(b);
 
-   if (ifp->if_bpf == NULL && sc->sc_sync_if == NULL) {
+   if (!bpf_peers_present(ifp->if_bpf) && sc->sc_sync_if == NULL) {
pfsync_drop(sc);
return;
}
@@ -1925,10 +1925,10 @@ pfsync_sendout(int schedswi, int c)
V_pfsyncstats.pfsyncs_oacts[PFSYNC_ACT_EOF]++;
 
/* we're done, let's put it on the wire */
-   if (ifp->if_bpf) {
+   if (bpf_peers_present(ifp->if_bpf)) {
m->m_data += aflen;
m->m_len = m->m_pkthdr.len = len - aflen;
-   BPF_MTAP(ifp, m);
+   bpf_mtap(ifp->if_bpf, m);
m->m_data -= aflen;
m->m_len = m->m_pkthdr.len = len;
}



git: 34c98f40f549 - main - net80211: Correct a comment

2024-06-19 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=34c98f40f549b3e5692aa5095448ff9135030f99

commit 34c98f40f549b3e5692aa5095448ff9135030f99
Author: Zhenlei Huang 
AuthorDate: 2024-06-20 04:27:43 +
Commit: Zhenlei Huang 
CommitDate: 2024-06-20 04:27:43 +

net80211: Correct a comment

MFC after:  3 days
---
 sys/net80211/ieee80211_radiotap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/net80211/ieee80211_radiotap.c 
b/sys/net80211/ieee80211_radiotap.c
index 34e27b323fc1..79e00106a780 100644
--- a/sys/net80211/ieee80211_radiotap.c
+++ b/sys/net80211/ieee80211_radiotap.c
@@ -125,7 +125,7 @@ ieee80211_radiotap_vattach(struct ieee80211vap *vap)
 void
 ieee80211_radiotap_vdetach(struct ieee80211vap *vap)
 {
-   /* NB: bpfattach is called by ether_ifdetach and claims all taps */
+   /* NB: bpfdetach is called by ether_ifdetach and claims all taps */
 }
 
 static void



git: 08a98731ddf4 - main - ip_mroute: Use NET_EPOCH_WAIT() macro

2024-06-24 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=08a98731ddf4459bcee25074bdbc21d6fa5ce4ca

commit 08a98731ddf4459bcee25074bdbc21d6fa5ce4ca
Author: Zhenlei Huang 
AuthorDate: 2024-06-24 09:57:14 +
Commit: Zhenlei Huang 
CommitDate: 2024-06-24 09:57:14 +

ip_mroute: Use NET_EPOCH_WAIT() macro

This makes it easier to grep the usage.

Reviewed by:kp
MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45715
---
 sys/netinet/ip_mroute.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c
index b864a4db5abc..afa199ce0691 100644
--- a/sys/netinet/ip_mroute.c
+++ b/sys/netinet/ip_mroute.c
@@ -768,7 +768,7 @@ X_ip_mrouter_done(void)
 * Wait for all epoch sections to complete to ensure
 * V_ip_mrouter = NULL is visible to others.
 */
-   epoch_wait_preempt(net_epoch_preempt);
+   NET_EPOCH_WAIT();
 
/* Stop and drain task queue */
taskqueue_block(V_task_queue);



git: 71f8fbf9bda4 - main - ifnet: Use NET_EPOCH_WAIT() macro

2024-06-24 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=71f8fbf9bda43e3ca2f26d0499b7a88d0f2f7352

commit 71f8fbf9bda43e3ca2f26d0499b7a88d0f2f7352
Author: Zhenlei Huang 
AuthorDate: 2024-06-24 09:57:14 +
Commit: Zhenlei Huang 
CommitDate: 2024-06-24 09:57:14 +

ifnet: Use NET_EPOCH_WAIT() macro

This makes it easier to grep the usage.

Reviewed by:kp
MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45715
---
 sys/net/if.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sys/net/if.c b/sys/net/if.c
index c3c27fbf678f..df405f088133 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -594,7 +594,7 @@ if_alloc_domain(u_char type, int numa_domain)
old = ifindex_table;
ck_pr_store_ptr(&ifindex_table, new);
if_indexlim = newlim;
-   epoch_wait_preempt(net_epoch_preempt);
+   NET_EPOCH_WAIT();
free(old, M_IFNET);
}
if (idx > if_index)
@@ -1132,7 +1132,7 @@ if_detach_internal(struct ifnet *ifp, bool vmove)
 * At this point we know the interface still was on the ifnet list
 * and we removed it so we are in a stable state.
 */
-   epoch_wait_preempt(net_epoch_preempt);
+   NET_EPOCH_WAIT();
 
/*
 * Ensure all pending EPOCH(9) callbacks have been executed. This
@@ -1544,7 +1544,7 @@ _if_delgroup_locked(struct ifnet *ifp, struct ifg_list 
*ifgl,
}
IFNET_WUNLOCK();
 
-   epoch_wait_preempt(net_epoch_preempt);
+   NET_EPOCH_WAIT();
EVENTHANDLER_INVOKE(group_change_event, groupname);
if (freeifgl) {
EVENTHANDLER_INVOKE(group_detach_event, ifgl->ifgl_group);



git: 2cb7605a2415 - main - lo: Use new KPI to create the first loop interface

2024-06-26 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=2cb7605a2415a1c0dd35374a88f815ef00e31de9

commit 2cb7605a2415a1c0dd35374a88f815ef00e31de9
Author: Zhenlei Huang 
AuthorDate: 2024-06-26 10:00:37 +
Commit: Zhenlei Huang 
CommitDate: 2024-06-26 10:00:37 +

lo: Use new KPI to create the first loop interface

While here remove a pointless static local variable lo_cloner.

No functional change intended.

Reviewed by:kp
MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45728
---
 sys/net/if_loop.c | 13 ++---
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/sys/net/if_loop.c b/sys/net/if_loop.c
index c5be3d17f447..926d264073ec 100644
--- a/sys/net/if_loop.c
+++ b/sys/net/if_loop.c
@@ -93,13 +93,9 @@ static int   looutput(struct ifnet *ifp, struct mbuf *m,
const struct sockaddr *dst, struct route *ro);
 
 VNET_DEFINE(struct ifnet *, loif); /* Used externally */
-
-#ifdef VIMAGE
 VNET_DEFINE_STATIC(struct if_clone *, lo_cloner);
 #defineV_lo_cloner VNET(lo_cloner)
-#endif
 
-static struct if_clone *lo_cloner;
 static const char loname[] = "lo";
 
 static int
@@ -141,8 +137,6 @@ lo_clone_create(struct if_clone *ifc, char *name, size_t 
len,
ifp->if_hwassist = LO_CSUM_FEATURES | LO_CSUM_FEATURES6;
if_attach(ifp);
bpfattach(ifp, DLT_NULL, sizeof(u_int32_t));
-   if (V_loif == NULL)
-   V_loif = ifp;
*ifpp = ifp;
 
return (0);
@@ -156,12 +150,9 @@ vnet_loif_init(const void *unused __unused)
.destroy_f = lo_clone_destroy,
.flags = IFC_F_AUTOUNIT,
};
-   lo_cloner = ifc_attach_cloner(loname, &req);
-#ifdef VIMAGE
-   V_lo_cloner = lo_cloner;
-#endif
+   V_lo_cloner = ifc_attach_cloner(loname, &req);
struct ifc_data ifd = { .unit = 0 };
-   ifc_create_ifp(loname, &ifd, NULL);
+   ifc_create_ifp(loname, &ifd, &V_loif);
 }
 VNET_SYSINIT(vnet_loif_init, SI_SUB_PSEUDO, SI_ORDER_ANY,
 vnet_loif_init, NULL);



git: ef4f4a44d913 - main - ifnet: Restore curvnet earlier

2024-06-26 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=ef4f4a44d9134ddadede0e2e6e658d0688c5ab3c

commit ef4f4a44d9134ddadede0e2e6e658d0688c5ab3c
Author: Zhenlei Huang 
AuthorDate: 2024-06-27 04:38:04 +
Commit: Zhenlei Huang 
CommitDate: 2024-06-27 04:38:04 +

ifnet: Restore curvnet earlier

This improves readability a little. As a side effect, a redundant
CURVNET_RESTORE is removed.

No functional change intended.

Reviewed by:glebius
MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45595
---
 sys/net/if.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/sys/net/if.c b/sys/net/if.c
index df405f088133..98be23e564c6 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -1343,8 +1343,8 @@ if_vmove_loan(struct thread *td, struct ifnet *ifp, char 
*ifname, int jid)
/* XXX Lock interfaces to avoid races. */
CURVNET_SET_QUIET(pr->pr_vnet);
difp = ifunit(ifname);
+   CURVNET_RESTORE();
if (difp != NULL) {
-   CURVNET_RESTORE();
prison_free(pr);
return (EEXIST);
}
@@ -1354,16 +1354,13 @@ if_vmove_loan(struct thread *td, struct ifnet *ifp, 
char *ifname, int jid)
shutdown = VNET_IS_SHUTTING_DOWN(ifp->if_vnet);
if (shutdown) {
sx_xunlock(&ifnet_detach_sxlock);
-   CURVNET_RESTORE();
prison_free(pr);
return (EBUSY);
}
-   CURVNET_RESTORE();
 
found = if_unlink_ifnet(ifp, true);
if (! found) {
sx_xunlock(&ifnet_detach_sxlock);
-   CURVNET_RESTORE();
prison_free(pr);
return (ENODEV);
}



git: aa3860851b9f - main - net: Remove unneeded NULL check for the allocated ifnet

2024-06-28 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=aa3860851b9f6a6002d135b1cac7736e0995eedc

commit aa3860851b9f6a6002d135b1cac7736e0995eedc
Author: Zhenlei Huang 
AuthorDate: 2024-06-28 10:16:29 +
Commit: Zhenlei Huang 
CommitDate: 2024-06-28 10:16:29 +

net: Remove unneeded NULL check for the allocated ifnet

Change 4787572d0580 made if_alloc_domain() never fail, then also do the
wrappers if_alloc(), if_alloc_dev(), and if_gethandle().

No functional change intended.

Reviewed by:kp, imp, glebius, stevek
MFC after:  2 weeks
Differential Revision:  https://reviews.freebsd.org/D45740
---
 sys/arm/allwinner/if_emac.c|  5 -
 sys/arm/ti/cpsw/if_cpsw.c  |  5 -
 sys/dev/ae/if_ae.c |  6 --
 sys/dev/age/if_age.c   |  6 --
 sys/dev/alc/if_alc.c   |  6 --
 sys/dev/ale/if_ale.c   |  6 --
 sys/dev/altera/atse/if_atse.c  |  5 -
 sys/dev/axgbe/if_axgbe.c   |  5 -
 sys/dev/bce/if_bce.c   |  6 --
 sys/dev/bfe/if_bfe.c   |  5 -
 sys/dev/bge/if_bge.c   |  5 -
 sys/dev/bxe/bxe.c  | 16 +++-
 sys/dev/cadence/if_cgem.c  |  5 -
 sys/dev/cas/if_cas.c   |  2 --
 sys/dev/cxgb/cxgb_main.c   |  5 -
 sys/dev/cxgbe/t4_main.c| 21 +
 sys/dev/cxgbe/t4_tracer.c  |  5 -
 sys/dev/dc/if_dc.c |  5 -
 sys/dev/dpaa/if_dtsec.c|  6 --
 sys/dev/dpaa2/dpaa2_ni.c   |  5 -
 sys/dev/ena/ena.c  | 17 +++--
 sys/dev/et/if_et.c |  5 -
 sys/dev/etherswitch/ar40xx/ar40xx_phy.c|  8 
 sys/dev/etherswitch/arswitch/arswitch.c|  6 --
 sys/dev/etherswitch/e6000sw/e6000sw.c  |  2 --
 sys/dev/etherswitch/e6000sw/e6060sw.c  |  6 --
 sys/dev/etherswitch/felix/felix.c  |  3 ---
 sys/dev/etherswitch/infineon/adm6996fc.c   |  6 --
 sys/dev/etherswitch/ip17x/ip17x.c  |  6 --
 sys/dev/etherswitch/micrel/ksz8995ma.c |  6 --
 sys/dev/etherswitch/mtkswitch/mtkswitch.c  |  6 --
 sys/dev/etherswitch/rtl8366/rtl8366rb.c|  6 --
 sys/dev/etherswitch/ukswitch/ukswitch.c|  6 --
 sys/dev/firewire/if_fwe.c  |  6 +-
 sys/dev/firewire/if_fwip.c |  4 +---
 sys/dev/fxp/if_fxp.c   |  5 -
 sys/dev/gem/if_gem.c   |  2 --
 sys/dev/gve/gve_main.c | 13 ++---
 sys/dev/iicbus/if_ic.c |  2 --
 sys/dev/jme/if_jme.c   |  6 --
 sys/dev/le/lance.c |  2 --
 sys/dev/lge/if_lge.c   |  5 -
 sys/dev/liquidio/lio_main.c|  5 -
 sys/dev/mana/mana_en.c |  5 -
 sys/dev/mge/if_mge.c   |  6 --
 sys/dev/mlx4/mlx4_en/mlx4_en_netdev.c  |  5 -
 sys/dev/mlx5/mlx5_en/mlx5_en_main.c|  6 --
 sys/dev/msk/if_msk.c   |  5 -
 sys/dev/mxge/if_mxge.c |  6 --
 sys/dev/my/if_my.c |  6 --
 sys/dev/neta/if_mvneta.c   |  5 -
 sys/dev/netmap/if_ptnet.c  |  6 --
 sys/dev/netmap/netmap_freebsd.c|  4 
 sys/dev/nfe/if_nfe.c   |  5 -
 sys/dev/nge/if_nge.c   |  5 -
 sys/dev/ntb/if_ntb/if_ntb.c|  4 
 sys/dev/oce/oce_if.c   | 13 +++--
 sys/dev/ppbus/if_plip.c|  4 
 sys/dev/qlnx/qlnxe/qlnx_os.c   |  4 
 sys/dev/qlxgb/qla_os.c |  3 ---
 sys/dev/qlxgbe/ql_os.c |  4 
 sys/dev/qlxge/qls_os.c |  4 
 sys/dev/re/if_re.c |  5 -
 sys/dev/rl/if_rl.c |  5 -
 sys/dev/sbni/if_sbni.c |  5 +
 sys/dev/sbni/if_sbni_isa.c |  7 +--
 sys/dev/sbni/if_sbni_pci.c | 17 +++--
 sys/dev/sbni

Re: git: aa3860851b9f - main - net: Remove unneeded NULL check for the allocated ifnet

2024-06-28 Thread Zhenlei Huang


> On Jun 28, 2024, at 6:38 PM, Poul-Henning Kamp  wrote:
> 
> ----
> Zhenlei Huang writes:
> 
>> commit aa3860851b9f6a6002d135b1cac7736e0995eedc
>> 
>>net: Remove unneeded NULL check for the allocated ifnet
>> 
>>Change 4787572d0580 made if_alloc_domain() never fail, then also do the
>>wrappers if_alloc(), if_alloc_dev(), and if_gethandle().
>> 
>> [...]
>> diff --git a/sys/arm/allwinner/if_emac.c b/sys/arm/allwinner/if_emac.c
>> index f581d361d3d9..1db43cbca26c 100644
>> --- a/sys/arm/allwinner/if_emac.c
>> +++ b/sys/arm/allwinner/if_emac.c
>> @@ -940,11 +940,6 @@ emac_attach(device_t dev)
>>  emac_reset(sc);
>> 
>>  ifp = sc->emac_ifp = if_alloc(IFT_ETHER);
>> -if (ifp == NULL) {
>> -device_printf(dev, "unable to allocate ifp\n");
>> -error = ENOSPC;
>> -goto fail;
>> -}
>>  if_setsoftc(ifp, sc);
>> 
>>  /* Setup MII */
> 
> I would like to suggest that we use a KASSERT() to document the
> expectations in cases like this.
> 
> It will costs us nothing, and it helps tell both human readers of
> the source code, the compiler, and code analysis tools what to
> expect.

I would recommend further, that, to have some compiler hints for
those kind of tasks. I think gcc extensions _Nullable _Nonnull could
fulfil but I have not tried yet.

Other language for example Java also have such means so that
the human labor can be freed.

There're also other kind of issues, such as do NULL check after malloc
with M_WAITOK flag. That is quite common but is more domain specific.
I guess simple compiler hints will not help, at least static code analyzer
is required.

More suggestions are welcomed!

> 
> Background:
> 
> One of the things I did with Varnish Cache was make asserts mandatory
> and numerous, to the point where about one source line in ten is an
> assert in our code base.
> 
> In Varnish asserts are not compiled out in production code, and so
> far nobody has ever documented any performance difference by doing so.
> 
> This is because almost all the asserts are on data already present
> in a CPU register at the time, and in many cases the compiler is
> even able to determine that the assert is always false and eliminates
> it before code generation.
> 
> But having the assert there still clearly states the expectation
> for both humans and programs.
> 
> For basic "is(n't) NULL" we have two short-hand assert macros:
> 
>   AZ(expression)  // is zero
>   AN(expression)  // is not zero/NULL
> 
> Maybe we should have something similar in sys/kassert.h ?
> 
> -- 
> Poul-Henning Kamp   | UNIX since Zilog Zeus 3.20
> p...@freebsd.org | TCP/IP since RFC 956
> FreeBSD committer   | BSD since 4.3-tahoe
> Never attribute to malice what can adequately be explained by incompetence.





git: 4ca4a3b1c8e3 - main - enc.4: Remove a redundant word

2024-06-30 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=4ca4a3b1c8e33cafcd9462e2d068246153846d57

commit 4ca4a3b1c8e33cafcd9462e2d068246153846d57
Author: Igor Ostapenko 
AuthorDate: 2024-06-30 09:27:05 +
Commit: Zhenlei Huang 
CommitDate: 2024-06-30 09:27:05 +

enc.4: Remove a redundant word

Reviewed by:zlei
MFC after:  3 days
Differential Revision:  https://reviews.freebsd.org/D45706
---
 share/man/man4/enc.4 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/share/man/man4/enc.4 b/share/man/man4/enc.4
index 87ff46878266..86f14d2bf290 100644
--- a/share/man/man4/enc.4
+++ b/share/man/man4/enc.4
@@ -126,7 +126,7 @@ The special value 0x4 can be configured in the
 .Ar ipsec_bpf_mask
 and packets will be also captured after firewall processing.
 .Sh EXAMPLES
-To see the packets the processed via
+To see the packets processed via
 .Xr ipsec 4 ,
 adjust the
 .Xr sysctl 8



git: 9738277b5c66 - main - ifnet: Remove dead code

2024-06-30 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=9738277b5c662a75347efa6a58daea485d30f895

commit 9738277b5c662a75347efa6a58daea485d30f895
Author: Zhenlei Huang 
AuthorDate: 2024-06-30 09:44:21 +
Commit: Zhenlei Huang 
CommitDate: 2024-06-30 09:44:21 +

ifnet: Remove dead code

Since change [1], if_bpf will not be detached by the interface departure
eventhandler and will not be NULL. Then the logic to re-attach if_bpf
becomes dead and serves no purpose any more.

This partially reverts commit 05fc416403ec.

1. 9ce40d321dd5 bpf: Fix incorrect cleanup

Reviewed by:kp
MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45599
---
 sys/net/if.c | 18 --
 1 file changed, 18 deletions(-)

diff --git a/sys/net/if.c b/sys/net/if.c
index 98be23e564c6..ee8fe533f338 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -1265,20 +1265,8 @@ finish_vnet_shutdown:
 static int
 if_vmove(struct ifnet *ifp, struct vnet *new_vnet)
 {
-#ifdef DEV_BPF
-   u_int bif_dlt, bif_hdrlen;
-#endif
int rc;
 
-#ifdef DEV_BPF
-   /*
-* if_detach_internal() will call the eventhandler to notify
-* interface departure.  That will detach if_bpf.  We need to
-* safe the dlt and hdrlen so we can re-attach it later.
-*/
-   bpf_get_bp_params(ifp->if_bpf, &bif_dlt, &bif_hdrlen);
-#endif
-
/*
 * Detach from current vnet, but preserve LLADDR info, do not
 * mark as dead etc. so that the ifnet can be reattached later.
@@ -1300,12 +1288,6 @@ if_vmove(struct ifnet *ifp, struct vnet *new_vnet)
 */
CURVNET_SET_QUIET(new_vnet);
if_attach_internal(ifp, true);
-
-#ifdef DEV_BPF
-   if (ifp->if_bpf == NULL)
-   bpfattach(ifp, bif_dlt, bif_hdrlen);
-#endif
-
CURVNET_RESTORE();
return (0);
 }



git: d6963b9ed328 - main - if_vxlan(4): Exclude ETHER_CRC_LEN from macro VXLAN_MAX_MTU

2024-07-01 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=d6963b9ed3287e91db3d1df153861591faff0007

commit d6963b9ed3287e91db3d1df153861591faff0007
Author: Zhenlei Huang 
AuthorDate: 2024-07-02 04:57:01 +
Commit: Zhenlei Huang 
CommitDate: 2024-07-02 04:57:01 +

if_vxlan(4): Exclude ETHER_CRC_LEN from macro VXLAN_MAX_MTU

The encapsulated (original) frame does not count in FCS as per Section 5
of RFC 7348.

Reviewed by:afedorov, bryanv, #network
Fixes:  b7592822d5de Allow set MTU more than 1500 bytes
MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45195
---
 sys/net/if_vxlan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/net/if_vxlan.c b/sys/net/if_vxlan.c
index 37f987981a0c..05430768cc73 100644
--- a/sys/net/if_vxlan.c
+++ b/sys/net/if_vxlan.c
@@ -97,7 +97,7 @@ struct vxlan_socket_mc_info {
60 /* Maximum IPv4 header len */ - \
sizeof(struct udphdr) - \
sizeof(struct vxlan_header) - \
-   ETHER_HDR_LEN - ETHER_CRC_LEN - ETHER_VLAN_ENCAP_LEN)
+   ETHER_HDR_LEN - ETHER_VLAN_ENCAP_LEN)
 #define VXLAN_BASIC_IFCAPS (IFCAP_LINKSTATE | IFCAP_JUMBO_MTU)
 
 #define VXLAN_SO_MC_MAX_GROUPS 32



git: 087f5e08ab5f - main - if_vxlan(4): Plug a memory leak

2024-07-01 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=087f5e08ab5f0384163f76f73b9a91c98a3ba450

commit 087f5e08ab5f0384163f76f73b9a91c98a3ba450
Author: Zhenlei Huang 
AuthorDate: 2024-07-02 04:57:02 +
Commit: Zhenlei Huang 
CommitDate: 2024-07-02 04:57:02 +

if_vxlan(4): Plug a memory leak

On clone creating, either failure from vxlan_set_user_config() or
ifc_copyin() will result in leaking previous allocated counters.

Since counter_u64_alloc(M_WAITOK) never fails, make vxlan_stats_alloc()
void and move the allocation for counters below checking ifd->params to
avoid memory leak.

Reviewed by:kp, glebius
Fixes:  b092fd6c973d if_vxlan(4): add support for hardware assisted 
checksumming, TSO, and RSS
MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45822
---
 sys/net/if_vxlan.c | 36 ++--
 1 file changed, 6 insertions(+), 30 deletions(-)

diff --git a/sys/net/if_vxlan.c b/sys/net/if_vxlan.c
index 05430768cc73..bb2de793550f 100644
--- a/sys/net/if_vxlan.c
+++ b/sys/net/if_vxlan.c
@@ -367,7 +367,7 @@ static bool vxlan_rcv_udp_packet(struct mbuf *, int, struct 
inpcb *,
 static int vxlan_input(struct vxlan_socket *, uint32_t, struct mbuf **,
const struct sockaddr *);
 
-static int vxlan_stats_alloc(struct vxlan_softc *);
+static voidvxlan_stats_alloc(struct vxlan_softc *);
 static voidvxlan_stats_free(struct vxlan_softc *);
 static voidvxlan_set_default_config(struct vxlan_softc *);
 static int vxlan_set_user_config(struct vxlan_softc *,
@@ -2923,27 +2923,14 @@ out:
return (error);
 }
 
-static int
+static void
 vxlan_stats_alloc(struct vxlan_softc *sc)
 {
struct vxlan_statistics *stats = &sc->vxl_stats;
 
stats->txcsum = counter_u64_alloc(M_WAITOK);
-   if (stats->txcsum == NULL)
-   goto failed;
-
stats->tso = counter_u64_alloc(M_WAITOK);
-   if (stats->tso == NULL)
-   goto failed;
-
stats->rxcsum = counter_u64_alloc(M_WAITOK);
-   if (stats->rxcsum == NULL)
-   goto failed;
-
-   return (0);
-failed:
-   vxlan_stats_free(sc);
-   return (ENOMEM);
 }
 
 static void
@@ -2951,18 +2938,9 @@ vxlan_stats_free(struct vxlan_softc *sc)
 {
struct vxlan_statistics *stats = &sc->vxl_stats;
 
-   if (stats->txcsum != NULL) {
-   counter_u64_free(stats->txcsum);
-   stats->txcsum = NULL;
-   }
-   if (stats->tso != NULL) {
-   counter_u64_free(stats->tso);
-   stats->tso = NULL;
-   }
-   if (stats->rxcsum != NULL) {
-   counter_u64_free(stats->rxcsum);
-   stats->rxcsum = NULL;
-   }
+   counter_u64_free(stats->txcsum);
+   counter_u64_free(stats->tso);
+   counter_u64_free(stats->rxcsum);
 }
 
 static void
@@ -3233,9 +3211,6 @@ vxlan_clone_create(struct if_clone *ifc, char *name, 
size_t len,
sc->vxl_unit = ifd->unit;
sc->vxl_fibnum = curthread->td_proc->p_fibnum;
vxlan_set_default_config(sc);
-   error = vxlan_stats_alloc(sc);
-   if (error != 0)
-   goto fail;
 
if (ifd->params != NULL) {
error = ifc_copyin(ifd, &vxlp, sizeof(vxlp));
@@ -3247,6 +3222,7 @@ vxlan_clone_create(struct if_clone *ifc, char *name, 
size_t len,
goto fail;
}
 
+   vxlan_stats_alloc(sc);
ifp = if_alloc(IFT_ETHER);
sc->vxl_ifp = ifp;
rm_init(&sc->vxl_lock, "vxlanrm");



git: a2cac544a668 - main - if_clone: Allow maxunit to be zero

2024-07-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=a2cac544a668d2834ed41986aca32b44b9819c89

commit a2cac544a668d2834ed41986aca32b44b9819c89
Author: Zhenlei Huang 
AuthorDate: 2024-07-03 13:14:08 +
Commit: Zhenlei Huang 
CommitDate: 2024-07-03 13:14:08 +

if_clone: Allow maxunit to be zero

Some drivers, e.g. if_enc(4), only allow one instance to be created, but
the KPI ifc_attach_cloner() treat zero value of maxunit as not limited,
aka IF_MAXUNIT.

Introduce a new flag IFC_F_LIMITUNIT to indicate that the requested
maxunit is limited and should be respected.

Consumers should use the new flag if there is an intended limit.

Reviewed by:glebius
MFC after:  2 weeks
Differential Revision:  https://reviews.freebsd.org/D45757
---
 sys/net/if_clone.c | 13 +
 sys/net/if_clone.h |  5 +
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/sys/net/if_clone.c b/sys/net/if_clone.c
index 8f1bad56d14e..13d89e4e2c59 100644
--- a/sys/net/if_clone.c
+++ b/sys/net/if_clone.c
@@ -483,12 +483,13 @@ if_clone_alloc(const char *name, int maxunit)
struct if_clone *ifc;
 
KASSERT(name != NULL, ("%s: no name\n", __func__));
+   MPASS(maxunit >= 0);
 
ifc = malloc(sizeof(struct if_clone), M_CLONE, M_WAITOK | M_ZERO);
strncpy(ifc->ifc_name, name, IFCLOSIZ-1);
IF_CLONE_LOCK_INIT(ifc);
IF_CLONE_ADDREF(ifc);
-   ifc->ifc_maxunit = maxunit ? maxunit : IF_MAXUNIT;
+   ifc->ifc_maxunit = maxunit;
ifc->ifc_unrhdr = new_unrhdr(0, ifc->ifc_maxunit, &ifc->ifc_mtx);
LIST_INIT(&ifc->ifc_iflist);
 
@@ -521,12 +522,16 @@ if_clone_attach(struct if_clone *ifc)
 struct if_clone *
 ifc_attach_cloner(const char *name, struct if_clone_addreq *req)
 {
+   int maxunit;
+   struct if_clone *ifc;
+
if (req->create_f == NULL || req->destroy_f == NULL)
return (NULL);
if (strnlen(name, IFCLOSIZ) >= (IFCLOSIZ - 1))
return (NULL);
 
-   struct if_clone *ifc = if_clone_alloc(name, req->maxunit);
+   maxunit = (req->flags & IFC_F_LIMITUNIT) ? req->maxunit : IF_MAXUNIT;
+   ifc = if_clone_alloc(name, maxunit);
ifc->ifc_match = req->match_f != NULL ? req->match_f : ifc_simple_match;
ifc->ifc_create = req->create_f;
ifc->ifc_destroy = req->destroy_f;
@@ -584,7 +589,7 @@ if_clone_advanced(const char *name, u_int maxunit, 
ifc_match_t match,
 {
struct if_clone *ifc;
 
-   ifc = if_clone_alloc(name, maxunit);
+   ifc = if_clone_alloc(name, maxunit ? maxunit : IF_MAXUNIT);
ifc->ifc_match = match;
ifc->ifc_create = ifc_advanced_create_wrapper;
ifc->ifc_destroy = ifc_advanced_destroy_wrapper;
@@ -629,7 +634,7 @@ if_clone_simple(const char *name, ifcs_create_t create, 
ifcs_destroy_t destroy,
struct if_clone *ifc;
u_int unit;
 
-   ifc = if_clone_alloc(name, 0);
+   ifc = if_clone_alloc(name, IF_MAXUNIT);
ifc->ifc_match = ifc_simple_match;
ifc->ifc_create = ifc_simple_create_wrapper;
ifc->ifc_destroy = ifc_simple_destroy_wrapper;
diff --git a/sys/net/if_clone.h b/sys/net/if_clone.h
index 45a6d4144230..e11fc5c8cdd7 100644
--- a/sys/net/if_clone.h
+++ b/sys/net/if_clone.h
@@ -101,6 +101,11 @@ struct if_clone_addreq_v2 {
 #defineIFC_F_SYSSPACE  0x04/* Cloner callback: params pointer is 
in kernel memory */
 #defineIFC_F_FORCE 0x08/* Deletion flag: force interface 
deletion */
 #defineIFC_F_CREATE0x10/* Creation flag: indicate creation 
request */
+#defineIFC_F_LIMITUNIT 0x20/* Creation flag: the unit number is 
limited */
+
+_Static_assert(offsetof(struct if_clone_addreq, destroy_f) ==
+offsetof(struct if_clone_addreq_v2, destroy_f),
+"destroy_f in if_clone_addreq and if_clone_addreq_v2 are at different 
offset");
 
 struct if_clone*ifc_attach_cloner(const char *name, struct 
if_clone_addreq *req);
 void ifc_detach_cloner(struct if_clone *ifc);



git: 07d138afc7e5 - main - if_pflog: Limit the maximum unit via the new KPI

2024-07-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=07d138afc7e5efee73368459dd047493713056cf

commit 07d138afc7e5efee73368459dd047493713056cf
Author: Zhenlei Huang 
AuthorDate: 2024-07-03 13:14:09 +
Commit: Zhenlei Huang 
CommitDate: 2024-07-03 13:14:09 +

if_pflog: Limit the maximum unit via the new KPI

The cloner has the ability to limit the maximum unit. Employ it to do
that rather than roll our own.

No functional change intended.

Reviewed by:kp
MFC after:  2 weeks
Differential Revision:  https://reviews.freebsd.org/D45767
---
 sys/netpfil/pf/if_pflog.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/sys/netpfil/pf/if_pflog.c b/sys/netpfil/pf/if_pflog.c
index 8b849b0b9376..6035ba635116 100644
--- a/sys/netpfil/pf/if_pflog.c
+++ b/sys/netpfil/pf/if_pflog.c
@@ -105,14 +105,16 @@ VNET_DEFINE(struct ifnet *, pflogifs[PFLOGIFS_MAX]);  
/* for fast access */
 static void
 pflogattach(int npflog __unused)
 {
-   int i;
+   int i;
+
for (i = 0; i < PFLOGIFS_MAX; i++)
V_pflogifs[i] = NULL;
 
struct if_clone_addreq req = {
.create_f = pflog_clone_create,
.destroy_f = pflog_clone_destroy,
-   .flags = IFC_F_AUTOUNIT,
+   .flags = IFC_F_AUTOUNIT | IFC_F_LIMITUNIT,
+   .maxunit = PFLOGIFS_MAX - 1,
};
V_pflog_cloner = ifc_attach_cloner(pflogname, &req);
struct ifc_data ifd = { .unit = 0 };
@@ -125,8 +127,7 @@ pflog_clone_create(struct if_clone *ifc, char *name, size_t 
maxlen,
 {
struct ifnet *ifp;
 
-   if (ifd->unit >= PFLOGIFS_MAX)
-   return (EINVAL);
+   MPASS(ifd->unit < PFLOGIFS_MAX);
 
ifp = if_alloc(IFT_PFLOG);
if_initname(ifp, pflogname, ifd->unit);



git: 09164454aa4c - main - ethernet: Retire M_HASFCS

2024-07-04 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=09164454aa4c1868abf1ea724ec6160c4a556bdd

commit 09164454aa4c1868abf1ea724ec6160c4a556bdd
Author: Zhenlei Huang 
AuthorDate: 2024-07-04 16:53:51 +
Commit: Zhenlei Huang 
CommitDate: 2024-07-04 16:53:51 +

ethernet: Retire M_HASFCS

The mbuf flag M_HASFCS was introduced for drivers to indicate the net
stack that packets include FCS (Frame Check Sequence). In principle, to
be efficient, FCS should always be processed by hardware, firmware, or
at last sort the driver. Well, Ethernet specifies that damaged frames
should be discarded, thus only good ones will be passed up to the net
stack, then it makes no senses for the net stack to see FCS just to trim
it.

The last consumer of the flag M_HASFCS has been removed since change [1].
It is time to retire it.

1. 105a4f7b3cb6 ng_atmllc: remove

Reviewed by:kp
MFC after:  never
Differential Revision:  https://reviews.freebsd.org/D42391
---
 sys/net/debugnet.c |  4 
 sys/net/ethernet.h |  1 -
 sys/net/if_ethersubr.c | 10 --
 3 files changed, 15 deletions(-)

diff --git a/sys/net/debugnet.c b/sys/net/debugnet.c
index c6f57ec84618..8b1419bcaa28 100644
--- a/sys/net/debugnet.c
+++ b/sys/net/debugnet.c
@@ -570,10 +570,6 @@ debugnet_input_one(struct ifnet *ifp, struct mbuf *m)
m->m_len, m->m_pkthdr.len);
goto done;
}
-   if ((m->m_flags & M_HASFCS) != 0) {
-   m_adj(m, -ETHER_CRC_LEN);
-   m->m_flags &= ~M_HASFCS;
-   }
eh = mtod(m, struct ether_header *);
etype = ntohs(eh->ether_type);
if ((m->m_flags & M_VLANTAG) != 0 || etype == ETHERTYPE_VLAN) {
diff --git a/sys/net/ethernet.h b/sys/net/ethernet.h
index e7313e78c5bb..cf92145eea8f 100644
--- a/sys/net/ethernet.h
+++ b/sys/net/ethernet.h
@@ -40,7 +40,6 @@
 /*
  * Ethernet-specific mbuf flags.
  */
-#defineM_HASFCSM_PROTO5/* FCS included at end of frame 
*/
 #defineM_BRIDGE_INJECT M_PROTO6/* if_bridge-injected frame */
 
 /*
diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c
index eeb2c1ea4ef3..6cd5cefa9609 100644
--- a/sys/net/if_ethersubr.c
+++ b/sys/net/if_ethersubr.c
@@ -588,16 +588,6 @@ ether_input_internal(struct ifnet *ifp, struct mbuf *m)
 */
ETHER_BPF_MTAP(ifp, m);
 
-   /*
-* If the CRC is still on the packet, trim it off. We do this once
-* and once only in case we are re-entered. Nothing else on the
-* Ethernet receive path expects to see the FCS.
-*/
-   if (m->m_flags & M_HASFCS) {
-   m_adj(m, -ETHER_CRC_LEN);
-   m->m_flags &= ~M_HASFCS;
-   }
-
if (!(ifp->if_capenable & IFCAP_HWSTATS))
if_inc_counter(ifp, IFCOUNTER_IBYTES, m->m_pkthdr.len);
 



git: a48f7a2eb90b - main - fibs: Suppress the WARNING message for setups with multiple fibs

2024-08-01 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=a48f7a2eb90b0812281e6d69bb05eb61433ea247

commit a48f7a2eb90b0812281e6d69bb05eb61433ea247
Author: Zhenlei Huang 
AuthorDate: 2024-08-01 17:48:58 +
Commit: Zhenlei Huang 
CommitDate: 2024-08-01 17:48:58 +

fibs: Suppress the WARNING message for setups with multiple fibs

Change 2d3982419593 switched net.add_addr_allfibs default to 0. The
warning message is for potential users of the feature. Well since all
supported releases have 0 as default, those potential users may have
already gotten the notification, emitting this WARNING every time
increasing the fib number is less useful but rather confusing to other
users. So let's suppress it right now.

PR: 280097
Reviewed by:markj
Differential Revision:  https://reviews.freebsd.org/D45971
---
 sys/net/route/route_tables.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/sys/net/route/route_tables.c b/sys/net/route/route_tables.c
index fd211bcd5dda..da829503b846 100644
--- a/sys/net/route/route_tables.c
+++ b/sys/net/route/route_tables.c
@@ -231,11 +231,6 @@ grow_rtables(uint32_t num_tables)
new_rt_tables = mallocarray(num_tables * (AF_MAX + 1), sizeof(void *),
M_RTABLE, M_WAITOK | M_ZERO);
 
-   if ((num_tables > 1) && (V_rt_add_addr_allfibs == 0))
-   printf("WARNING: Adding ifaddrs to all fibs has been turned off 
"
-   "by default. Consider tuning %s if needed\n",
-   "net.add_addr_allfibs");
-
 #ifdef FIB_ALGO
fib_grow_rtables(num_tables);
 #endif



Re: git: 9b569353e0b0 - main - tcp: initialize V_ts_offset_secret for all vnets

2024-08-09 Thread Zhenlei Huang



> On Aug 9, 2024, at 10:15 PM, Michael Tuexen  wrote:
> 
> The branch main has been updated by tuexen:
> 
> URL: 
> https://cgit.FreeBSD.org/src/commit/?id=9b569353e0b073a513cf10debbe634c2ceb29fdf
> 
> commit 9b569353e0b073a513cf10debbe634c2ceb29fdf
> Author: Michael Tuexen 
> AuthorDate: 2024-08-09 14:12:22 +
> Commit: Michael Tuexen 
> CommitDate: 2024-08-09 14:12:22 +
> 
>tcp: initialize V_ts_offset_secret for all vnets
> 
>Initialize V_ts_offset_secret for each vnet, not only for the
>default vnet, since it is vnet specific.
> 
>Reviewed by:Peter Lei
>MFC after:  3 days
>Sponsored by:   Netflix, Inc.
>Differential Revision:  https://reviews.freebsd.org/D46246
> ---
> sys/netinet/tcp_subr.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c
> index 9e95a87b3596..9b5f2651fb35 100644
> --- a/sys/netinet/tcp_subr.c
> +++ b/sys/netinet/tcp_subr.c
> @@ -1465,6 +1465,7 @@ tcp_vnet_init(void *arg __unused)
>   VNET_PCPUSTAT_ALLOC(tcpstat, M_WAITOK);
> 
>   V_tcp_msl = TCPTV_MSL;
> + arc4rand(&V_ts_offset_secret, sizeof(V_ts_offset_secret), 0);

Emm, does it have any (potential) security problems if not initialized ? If yes 
then does it deserve an SA ?

> }
> VNET_SYSINIT(tcp_vnet_init, SI_SUB_PROTO_DOMAIN, SI_ORDER_FOURTH,
> tcp_vnet_init, NULL);
> @@ -1502,7 +1503,6 @@ tcp_init(void *arg __unused)
>   /* Initialize the TCP logging data. */
>   tcp_log_init();
> #endif
> - arc4rand(&V_ts_offset_secret, sizeof(V_ts_offset_secret), 0);
> 
>   if (tcp_soreceive_stream) {
> #ifdef INET






Re: git: d5507f9e4366 - main - nvme: Separate total failures from I/O failures

2024-08-15 Thread Zhenlei Huang
Hi Warner,

I'm not sure but this change seems include lots of unintended changes ( maybe 
some local WIP ) .

> On Aug 16, 2024, at 10:30 AM, Warner Losh  wrote:
> 
> The branch main has been updated by imp:
> 
> URL: 
> https://cgit.FreeBSD.org/src/commit/?id=d5507f9e436698ac17dc5ace7ef58493988a9b04
> 
> commit d5507f9e436698ac17dc5ace7ef58493988a9b04
> Author: Warner Losh 
> AuthorDate: 2024-08-14 22:55:49 +
> Commit: Warner Losh 
> CommitDate: 2024-08-16 02:22:18 +
> 
>nvme: Separate total failures from I/O failures
> 
>When it's a I/O failure, we can still send admin commands. Separate out
>the admin failures and flag them as such so that we can still send admin
>commands on half-failed drives.
> 
>Fixes: 9229b3105d88 (nvme: Fail passthrough commands right away in failed 
> state)
>Sponsored by: Netflix
> ---
> sys/amd64/conf/IOSCHED |2 +
> sys/amd64/conf/MPI3MR  |   10 +
> sys/arm64/conf/GENERIC16K  |4 +
> .../linuxkpi/common/include/linux/#compiler.h# |  117 +
> sys/contrib/dev/iwlwifi/fw/api/soc.h   |   35 +
> sys/contrib/zlib/contrib/asm686/README.686 |   51 +
> sys/contrib/zlib/contrib/asm686/match.S|  357 +
> sys/dev/ice/ice_sriov.c|  595 ++
> sys/dev/ice/ice_sriov.h|   64 +
> sys/dev/mps/mpi/mpi2_pci.h |  141 +
> sys/dev/nvme/nvme_ctrlr.c  |   46 +-
> sys/dev/nvme/nvme_private.h|1 +
> sys/dev/nvme/nvme_qpair.c  |   23 +-
> sys/dev/nvme/nvme_sim.c|   13 +-
> sys/dev/sound/pci/aureal.c |  686 ++
> sys/dev/sound/pci/aureal.h |   99 +
> sys/dev/sound/pci/ds1-fw.h | 1602 
> sys/dev/sound/pci/ds1.c| 1103 +++
> sys/dev/sound/pci/ds1.h|  146 +
> sys/dev/sound/pci/maestro.c| 2043 +
> sys/dev/sound/pci/maestro_reg.h|  381 +
> sys/kern/bsduser-syscalls.c| 8712 
> sys/modules/sound/driver/ds1/Makefile  |8 +
> sys/modules/sound/driver/maestro/Makefile  |8 +
> 24 files changed, 16219 insertions(+), 28 deletions(-)
> 
> diff --git a/sys/amd64/conf/IOSCHED b/sys/amd64/conf/IOSCHED
> new file mode 100644
> index ..e15106bc4c1f
> --- /dev/null
> +++ b/sys/amd64/conf/IOSCHED
> @@ -0,0 +1,2 @@
> +include "GENERIC"
> +options CAM_IOSCHED_DYNAMIC
> diff --git a/sys/amd64/conf/MPI3MR b/sys/amd64/conf/MPI3MR
> new file mode 100644
> index ..99e5244cb49d
> --- /dev/null
> +++ b/sys/amd64/conf/MPI3MR
> @@ -0,0 +1,10 @@
> +include GENERIC
> +
> +device mpi3mr
> +# All the debugging options
> +options DEADLKRES # Enable the deadlock resolver
> +options INVARIANTS # Enable calls of extra sanity checking
> +options INVARIANT_SUPPORT # Extra sanity checks of internal structures, 
> required by INVARIANTS
> +options QUEUE_MACRO_DEBUG_TRASH # Trash queue(2) internal pointers on 
> invalidation
> +options WITNESS # Enable checks to detect deadlocks and cycles
> +options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed
> diff --git a/sys/arm64/conf/GENERIC16K b/sys/arm64/conf/GENERIC16K
> new file mode 100644
> index ..9bf9e2dadb08
> --- /dev/null
> +++ b/sys/arm64/conf/GENERIC16K
> @@ -0,0 +1,4 @@
> +include  "GENERIC"
> +
> +identGENERIC_16K
> +
> diff --git a/sys/compat/linuxkpi/common/include/linux/#compiler.h# 
> b/sys/compat/linuxkpi/common/include/linux/#compiler.h#
> new file mode 100644
> index ..1177674aa68f
> --- /dev/null
> +++ b/sys/compat/linuxkpi/common/include/linux/#compiler.h#
> @@ -0,0 +1,117 @@
> +/*-
> + * Copyright (c) 2010 Isilon Systems, Inc.
> + * Copyright (c) 2010 iX Systems, Inc.
> + * Copyright (c) 2010 Panasas, Inc.
> + * Copyright (c) 2013-2016 Mellanox Technologies, Ltd.
> + * Copyright (c) 2015 François Tigeot
> + * All rights reserved.
> + *
> + * Redistribution and use in source and binary forms, with or without
> + * modification, are permitted provided that the following conditions
> + * are met:
> + * 1. Redistributions of source code must retain the above copyright
> + *notice unmodified, this list of conditions, and the following
> + *disclaimer.
> + * 2. Redistributions in binary form must reproduce the above copyright
> + *notice, this list of conditions and the following disclaimer in the
> + *documentation and/or other materials provided with the distribution.
> + *
> + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
> + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
> + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
>

git: 7412517f2947 - main - init_main: Sprinkle const qualifiers where appropriate

2024-08-21 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=7412517f2947342d599e42dd563fd6b3a7656e29

commit 7412517f2947342d599e42dd563fd6b3a7656e29
Author: Zhenlei Huang 
AuthorDate: 2024-08-21 10:01:30 +
Commit: Zhenlei Huang 
CommitDate: 2024-08-21 10:01:30 +

init_main: Sprinkle const qualifiers where appropriate

No functional change intended.

MFC after:  1 week
---
 sys/kern/init_main.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c
index 7386a0729835..9d2663015027 100644
--- a/sys/kern/init_main.c
+++ b/sys/kern/init_main.c
@@ -347,13 +347,13 @@ mi_startup(void)
 }
 
 static void
-print_caddr_t(void *data)
+print_caddr_t(const void *data)
 {
-   printf("%s", (char *)data);
+   printf("%s", (const char *)data);
 }
 
 static void
-print_version(void *data __unused)
+print_version(const void *data __unused)
 {
int len;
 



git: 0f64fc6a3486 - main - kern: Align the declaration of kernconfstring with its definition

2024-08-22 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=0f64fc6a3486454ad708f517633f930e611fd6d2

commit 0f64fc6a3486454ad708f517633f930e611fd6d2
Author: Zhenlei Huang 
AuthorDate: 2024-08-22 10:00:34 +
Commit: Zhenlei Huang 
CommitDate: 2024-08-22 10:00:34 +

kern: Align the declaration of kernconfstring with its definition

It is defined as const char[] in config.c which is auto generated by
usr.sbin/config/kernconf.tmpl .

While here prefer macro SYSCTL_CONST_STRING to avoid casting.

MFC after:  1 week
---
 sys/kern/kern_mib.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sys/kern/kern_mib.c b/sys/kern/kern_mib.c
index fe6e49865682..0132478aa68a 100644
--- a/sys/kern/kern_mib.c
+++ b/sys/kern/kern_mib.c
@@ -464,10 +464,10 @@ SYSCTL_PROC(_kern, KERN_SECURELVL, securelevel,
 
 #ifdef INCLUDE_CONFIG_FILE
 /* Actual kernel configuration options. */
-extern char kernconfstring[];
+extern const char kernconfstring[];
 
-SYSCTL_STRING(_kern, OID_AUTO, conftxt, CTLFLAG_RD,
-kernconfstring, 0, "Kernel configuration file");
+SYSCTL_CONST_STRING(_kern, OID_AUTO, conftxt, CTLFLAG_RD,
+kernconfstring, "Kernel configuration file");
 #endif
 
 static int



git: 356be1348dac - main - kernel: Make some compile time constant variables const

2024-08-30 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=356be1348dac94ba0d2dc1f479bc1f8a2ebaa03a

commit 356be1348dac94ba0d2dc1f479bc1f8a2ebaa03a
Author: Zhenlei Huang 
AuthorDate: 2024-08-30 10:26:30 +
Commit: Zhenlei Huang 
CommitDate: 2024-08-30 10:26:30 +

kernel: Make some compile time constant variables const

Those variables are not going to be changed at runtime. Make them const
to avoid potential overwriting. This will also help spotting accidental
global variables shadowing, since the variable's name such as `version`
is short and commonly used.

This change was inspired by reviewing khng's work D44760.

No functional change intended.

MFC after:  2 weeks
Differential Revision:  https://reviews.freebsd.org/D45227
---
 sys/arm/arm/identcpu-v6.c |  6 +++---
 sys/arm64/arm64/identcpu.c|  2 +-
 sys/conf/newvers.sh   | 14 +++---
 sys/kern/init_main.c  | 24 
 sys/kern/kern_mib.c   | 16 
 sys/powerpc/powerpc/machdep.c |  5 +++--
 sys/riscv/riscv/identcpu.c|  6 +++---
 sys/sys/copyright.h   |  4 ++--
 sys/sys/sysctl.h  |  8 
 sys/sys/systm.h   |  8 
 sys/x86/x86/identcpu.c|  6 +++---
 11 files changed, 50 insertions(+), 49 deletions(-)

diff --git a/sys/arm/arm/identcpu-v6.c b/sys/arm/arm/identcpu-v6.c
index 34663dfa51e6..3dd218696a19 100644
--- a/sys/arm/arm/identcpu-v6.c
+++ b/sys/arm/arm/identcpu-v6.c
@@ -49,10 +49,10 @@
 #include 
 #include 
 
-char machine[] = "arm";
+const char machine[] = "arm";
 
-SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD | CTLFLAG_CAPRD,
-   machine, 0, "Machine class");
+SYSCTL_CONST_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD | CTLFLAG_CAPRD,
+machine, "Machine class");
 
 static char cpu_model[64];
 SYSCTL_STRING(_hw, HW_MODEL, model, CTLFLAG_RD | CTLFLAG_CAPRD,
diff --git a/sys/arm64/arm64/identcpu.c b/sys/arm64/arm64/identcpu.c
index 5fec7cba385f..eead0051d315 100644
--- a/sys/arm64/arm64/identcpu.c
+++ b/sys/arm64/arm64/identcpu.c
@@ -59,7 +59,7 @@ static void print_cpu_caches(struct sbuf *sb, struct cpu_desc 
*desc);
 static u_long parse_cpu_features_hwcap32(void);
 #endif
 
-char machine[] = "arm64";
+const char machine[] = "arm64";
 
 #ifdef SCTL_MASK32
 extern int adaptive_machine_arch;
diff --git a/sys/conf/newvers.sh b/sys/conf/newvers.sh
index 908e3bfa660a..481af5480399 100644
--- a/sys/conf/newvers.sh
+++ b/sys/conf/newvers.sh
@@ -312,13 +312,13 @@ $COPYRIGHT
 #define VERSTR "${VERSTR}"
 #define RELSTR "${RELEASE}"
 
-char sccs[sizeof(SCCSSTR) > 128 ? sizeof(SCCSSTR) : 128] = SCCSSTR;
-char version[sizeof(VERSTR) > 256 ? sizeof(VERSTR) : 256] = VERSTR;
-char compiler_version[] = "${compiler_v}";
-char ostype[] = "${TYPE}";
-char osrelease[sizeof(RELSTR) > 32 ? sizeof(RELSTR) : 32] = RELSTR;
-int osreldate = ${RELDATE};
-char kern_ident[] = "${i}";
+const char sccs[sizeof(SCCSSTR) > 128 ? sizeof(SCCSSTR) : 128] = SCCSSTR;
+const char version[sizeof(VERSTR) > 256 ? sizeof(VERSTR) : 256] = VERSTR;
+const char compiler_version[] = "${compiler_v}";
+const char ostype[] = "${TYPE}";
+const char osrelease[sizeof(RELSTR) > 32 ? sizeof(RELSTR) : 32] = RELSTR;
+const int osreldate = ${RELDATE};
+const char kern_ident[] = "${i}";
 EOF
 )
 vers_content_old=$(cat vers.c 2>/dev/null || true)
diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c
index 9d2663015027..fed5340695cf 100644
--- a/sys/kern/init_main.c
+++ b/sys/kern/init_main.c
@@ -365,36 +365,36 @@ print_version(const void *data __unused)
printf("%s\n", compiler_version);
 }
 
-SYSINIT(announce, SI_SUB_COPYRIGHT, SI_ORDER_FIRST, print_caddr_t,
+C_SYSINIT(announce, SI_SUB_COPYRIGHT, SI_ORDER_FIRST, print_caddr_t,
 copyright);
-SYSINIT(trademark, SI_SUB_COPYRIGHT, SI_ORDER_SECOND, print_caddr_t,
+C_SYSINIT(trademark, SI_SUB_COPYRIGHT, SI_ORDER_SECOND, print_caddr_t,
 trademark);
-SYSINIT(version, SI_SUB_COPYRIGHT, SI_ORDER_THIRD, print_version, NULL);
+C_SYSINIT(version, SI_SUB_COPYRIGHT, SI_ORDER_THIRD, print_version, NULL);
 
 #ifdef WITNESS
-static char wit_warn[] =
+static const char wit_warn[] =
  "WARNING: WITNESS option enabled, expect reduced performance.\n";
-SYSINIT(witwarn, SI_SUB_COPYRIGHT, SI_ORDER_FOURTH,
+C_SYSINIT(witwarn, SI_SUB_COPYRIGHT, SI_ORDER_FOURTH,
print_caddr_t, wit_warn);
-SYSINIT(witwarn2, SI_SUB_LAST, SI_ORDER_FOURTH,
+C_SYSINIT(witwarn2, SI_SUB_LAST, SI_ORDER_FOURTH,
print_caddr_t, wit_warn);
 #endif
 
 #ifdef DIAGNOSTIC
-static char diag_warn[] =
+static const char diag_warn[] =
  "WARNING: DIAGNOSTIC option enabled, expect reduced performance.\n";
-SYSINIT(diagwarn, SI_SUB_COPYRIGHT, 

git: e15b5ba77d69 - main - kernel: Fix defining of .init_array and .fini_array sections

2024-09-01 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=e15b5ba77d693609c9a452d1b0a1cdd5eb29350d

commit e15b5ba77d693609c9a452d1b0a1cdd5eb29350d
Author: Zhenlei Huang 
AuthorDate: 2024-09-02 04:26:47 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-02 04:26:47 +

kernel: Fix defining of .init_array and .fini_array sections

These input sections can have decimal numbers as the priority suffix.
Clang emits the '%u' form, while SORT is an alias for SORT_BY_NAME,
hence will result in wrong order of constructors / destructors in
output sections. Fix by using the correct sorting command
SORT_BY_INIT_PRIORITY instead [1].

The functions referenced by section .fini_array is in the normal order,
but been executed in the reverse order. The order is same with
.init_array section.

Currently these sections are not used, there should be no functional
change.

Note: As for the .ctors and .dtors sections, both Clang and GCC emit
the priority suffix in the form of '%05u', so there is no semantic
difference between SORT_BY_NAME and SORT_BY_INIT_PRIORITY for those
sections [2].

This fix is extracted from a bigger patch [3] of hselasky, with
additional fix for .fini_array section.

1. https://sourceware.org/binutils/docs/ld/Input-Section-Wildcards.html
2. https://reviews.llvm.org/D91187
3. https://reviews.freebsd.org/D40467

Reviewed by:imp (previous version)
Obtained from:  hselasky
MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45194
---
 sys/conf/ldscript.amd64 | 4 ++--
 sys/conf/ldscript.i386  | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/sys/conf/ldscript.amd64 b/sys/conf/ldscript.amd64
index b3286612b41a..1c7fde2eada0 100644
--- a/sys/conf/ldscript.amd64
+++ b/sys/conf/ldscript.amd64
@@ -93,15 +93,15 @@ SECTIONS
   .init_array :
   {
  PROVIDE_HIDDEN (__init_array_start = .);
- KEEP (*(SORT(.init_array.*)))
+ KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*)))
  KEEP (*(.init_array))
  PROVIDE_HIDDEN (__init_array_end = .);
   }
   .fini_array :
   {
 PROVIDE_HIDDEN (__fini_array_start = .);
+KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*)))
 KEEP (*(.fini_array))
-KEEP (*(SORT(.fini_array.*)))
 PROVIDE_HIDDEN (__fini_array_end = .);
   }
   _start_ctors = .;
diff --git a/sys/conf/ldscript.i386 b/sys/conf/ldscript.i386
index 66bdbc4a80cb..467cba24d43f 100644
--- a/sys/conf/ldscript.i386
+++ b/sys/conf/ldscript.i386
@@ -87,15 +87,15 @@ SECTIONS
   .init_array :
   {
  PROVIDE_HIDDEN (__init_array_start = .);
- KEEP (*(SORT(.init_array.*)))
+ KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*)))
  KEEP (*(.init_array))
  PROVIDE_HIDDEN (__init_array_end = .);
   }
   .fini_array :
   {
 PROVIDE_HIDDEN (__fini_array_start = .);
+KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*)))
 KEEP (*(.fini_array))
-KEEP (*(SORT(.fini_array.*)))
 PROVIDE_HIDDEN (__fini_array_end = .);
   }
   _start_ctors = .;



git: 3e76d05231b0 - main - kernel: Add defination of .init_array and .fini_array for all other platforms

2024-09-01 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=3e76d05231b0aa77d922bdbc9abf62d9747a91ab

commit 3e76d05231b0aa77d922bdbc9abf62d9747a91ab
Author: Zhenlei Huang 
AuthorDate: 2024-09-02 04:26:48 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-02 04:26:48 +

kernel: Add defination of .init_array and .fini_array for all other 
platforms

Currently these sections are not used but defined only for amd64 and
i386. Added them for all other platforms to keep all platforms in sync.
There should be no functional change.

This change is extracted from a bigger patch [1] of hselasky, with
additional fix for the order of .fini_array section.

1. https://reviews.freebsd.org/D40467

Obtained from:  hselasky
MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45214
---
 sys/conf/ldscript.arm | 14 ++
 sys/conf/ldscript.arm64   | 14 ++
 sys/conf/ldscript.powerpc | 16 ++--
 sys/conf/ldscript.powerpc64   | 15 ++-
 sys/conf/ldscript.powerpc64le | 15 ++-
 sys/conf/ldscript.powerpcspe  | 16 ++--
 sys/conf/ldscript.riscv   | 14 ++
 7 files changed, 98 insertions(+), 6 deletions(-)

diff --git a/sys/conf/ldscript.arm b/sys/conf/ldscript.arm
index 0764c99f9042..e8d2db3f854b 100644
--- a/sys/conf/ldscript.arm
+++ b/sys/conf/ldscript.arm
@@ -83,6 +83,20 @@ SECTIONS
   }
   .data1   : { *(.data1) }
   . = ALIGN(32 / 8);
+  .init_array:
+  {
+PROVIDE_HIDDEN (__init_array_start = .);
+KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*)))
+KEEP (*(.init_array))
+PROVIDE_HIDDEN (__init_array_end = .);
+  }
+  .fini_array:
+  {
+PROVIDE_HIDDEN (__fini_array_start = .);
+KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*)))
+KEEP (*(.fini_array))
+PROVIDE_HIDDEN (__fini_array_end = .);
+  }
   _start_ctors = .;
   PROVIDE (start_ctors = .);
   .ctors :
diff --git a/sys/conf/ldscript.arm64 b/sys/conf/ldscript.arm64
index 32af035105d0..0d50eef431cf 100644
--- a/sys/conf/ldscript.arm64
+++ b/sys/conf/ldscript.arm64
@@ -100,6 +100,20 @@ SECTIONS
   . = ALIGN(128);
   .data1   : { *(.data1) }
   . = ALIGN(32 / 8);
+  .init_array:
+  {
+PROVIDE_HIDDEN (__init_array_start = .);
+KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*)))
+KEEP (*(.init_array))
+PROVIDE_HIDDEN (__init_array_end = .);
+  }
+  .fini_array:
+  {
+PROVIDE_HIDDEN (__fini_array_start = .);
+KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*)))
+KEEP (*(.fini_array))
+PROVIDE_HIDDEN (__fini_array_end = .);
+  }
   _start_ctors = .;
   PROVIDE (start_ctors = .);
   .ctors :
diff --git a/sys/conf/ldscript.powerpc b/sys/conf/ldscript.powerpc
index 0e11dd4459db..3a407a4dbf88 100644
--- a/sys/conf/ldscript.powerpc
+++ b/sys/conf/ldscript.powerpc
@@ -78,8 +78,20 @@ SECTIONS
   . = ALIGN(4096);
   .got: { *(.got) }
   .got.plt: { *(.got.plt) }
-
-
+  .init_array :
+  {
+PROVIDE_HIDDEN (__init_array_start = .);
+KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*)))
+KEEP (*(.init_array))
+PROVIDE_HIDDEN (__init_array_end = .);
+  }
+  .fini_array :
+  {
+PROVIDE_HIDDEN (__fini_array_start = .);
+KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*)))
+KEEP (*(.fini_array))
+PROVIDE_HIDDEN (__fini_array_end = .);
+  }
   .dynamic: { *(.dynamic) } :kernel :dynamic
   /* Put .ctors and .dtors next to the .got2 section, so that the pointers
  get relocated with -mrelocatable. Also put in the .fixup pointers.
diff --git a/sys/conf/ldscript.powerpc64 b/sys/conf/ldscript.powerpc64
index 58a3dc69931b..a342a48b9daf 100644
--- a/sys/conf/ldscript.powerpc64
+++ b/sys/conf/ldscript.powerpc64
@@ -104,7 +104,20 @@ SECTIONS
   . = ALIGN(4096);
   .got   : ALIGN(8) { __tocbase = .; *(.got) }
   .toc   : ALIGN(8) { *(.toc) }
-
+  .init_array :
+  {
+PROVIDE_HIDDEN (__init_array_start = .);
+KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*)))
+KEEP (*(.init_array))
+PROVIDE_HIDDEN (__init_array_end = .);
+  }
+  .fini_array :
+  {
+PROVIDE_HIDDEN (__fini_array_start = .);
+KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*)))
+KEEP (*(.fini_array))
+PROVIDE_HIDDEN (__fini_array_end = .);
+  }
   .dynamic: { *(.dynamic) } :kernel :dynamic
   /* Put .ctors and .dtors next to the .got2 section, so that the pointers
  get relocated with -mrelocatable. Also put in the .fixup pointers.
diff --git a/sys/conf/ldscript.powerpc64le b/sys/conf/ldscript.powerpc64le
index a65b39b3d9eb..1d5f3efe64fd 100644
--- a/sys/conf/ldscript.powerpc64le
+++ b/sys/conf/ldscript.powerpc64le
@@ -104,7 +104,20 @@ SECTIONS
   . = ALIGN(4096);
   .got   : ALIGN(8) { __tocbase = .; *(.got) }
   .toc   : ALIGN(8) { *(.toc) }
-
+  .init_array :
+  {
+PROVIDE_HIDDEN (__init_array_start = .);
+KEEP

git: 209905ec384e - main - ndp: Fix libxo formatting for the header of neighbor cache

2024-09-02 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=209905ec384eedd58f1b9b7ab774029d22787dfb

commit 209905ec384eedd58f1b9b7ab774029d22787dfb
Author: Helge Oldach 
AuthorDate: 2024-09-02 10:12:43 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-02 10:15:15 +

ndp: Fix libxo formatting for the header of neighbor cache

PR: 272749
Reviewed by:zlei
Fixes:  e1c7783e220b ndp(8): add structured output formatting via 
libxo
Fixes:  91fbe0819bb9 ndp: convert ndp(8) to netlink
MFC after:  3 days
---
 usr.sbin/ndp/ndp.c | 2 +-
 usr.sbin/ndp/ndp_netlink.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/usr.sbin/ndp/ndp.c b/usr.sbin/ndp/ndp.c
index 637aac2823ed..7c7bc60451c8 100644
--- a/usr.sbin/ndp/ndp.c
+++ b/usr.sbin/ndp/ndp.c
@@ -633,7 +633,7 @@ dump_rtsock(struct sockaddr_in6 *addr, int cflag)
if (!opts.tflag && !cflag) {
char xobuf[200];
snprintf(xobuf, sizeof(xobuf),
-   "{T:/%%-%d.%ds} {T:/%%-%d.%ds} {T:/%%%d.%ds} {T:/%%-9.9s} 
{T:%%1s} {T:%%5s}\n",
+   "{T:/%%-%d.%ds} {T:/%%-%d.%ds} {T:/%%%d.%ds} {T:/%%-9.9s} 
{T:/%%1s} {T:/%%5s}\n",
W_ADDR, W_ADDR, W_LL, W_LL, W_IF, W_IF);
xo_emit(xobuf, "Neighbor", "Linklayer Address", "Netif", 
"Expire", "S", "Flags");
}
diff --git a/usr.sbin/ndp/ndp_netlink.c b/usr.sbin/ndp/ndp_netlink.c
index e18d64175619..bafa9f2a143d 100644
--- a/usr.sbin/ndp/ndp_netlink.c
+++ b/usr.sbin/ndp/ndp_netlink.c
@@ -341,7 +341,7 @@ print_entries_nl(uint32_t ifindex, struct sockaddr_in6 
*addr, bool cflag)
if (!opts.tflag && !cflag) {
char xobuf[200];
snprintf(xobuf, sizeof(xobuf),
-   "{T:/%%-%d.%ds} {T:/%%-%d.%ds} {T:/%%%d.%ds} {T:/%%-9.9s} 
{T:%%1s} {T:%%5s}\n",
+   "{T:/%%-%d.%ds} {T:/%%-%d.%ds} {T:/%%%d.%ds} {T:/%%-9.9s} 
{T:/%%1s} {T:/%%5s}\n",
W_ADDR, W_ADDR, W_LL, W_LL, W_IF, W_IF);
xo_emit(xobuf, "Neighbor", "Linklayer Address", "Netif", 
"Expire", "S", "Flags");
}



git: 6a2a385507c7 - main - kern_fail: Stop checking for failures from fp_malloc(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=6a2a385507c79abaa9db9eabfdd827362f3dc7ed

commit 6a2a385507c79abaa9db9eabfdd827362f3dc7ed
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:16 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:16 +

kern_fail: Stop checking for failures from fp_malloc(M_WAITOK)

`fp_malloc` is defined as a macro that redirects to `malloc`.

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45852
---
 sys/kern/kern_fail.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/sys/kern/kern_fail.c b/sys/kern/kern_fail.c
index 883b664aef0d..258268bb874f 100644
--- a/sys/kern/kern_fail.c
+++ b/sys/kern/kern_fail.c
@@ -479,11 +479,10 @@ fail_point_init(struct fail_point *fp, const char *fmt, 
...)
 
/* Allocate the name and fill it in. */
name = fp_malloc(n + 1, M_WAITOK);
-   if (name != NULL) {
-   va_start(ap, fmt);
-   vsnprintf(name, n + 1, fmt, ap);
-   va_end(ap);
-   }
+   va_start(ap, fmt);
+   vsnprintf(name, n + 1, fmt, ap);
+   va_end(ap);
+
fp->fp_name = name;
fp->fp_location = "";
fp->fp_flags |= FAIL_POINT_DYNAMIC_NAME;



git: f444db950e87 - main - boottrace: Stop checking for failures from realloc(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=f444db950e877596805aed897c3fbb975be28711

commit f444db950e877596805aed897c3fbb975be28711
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:17 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:17 +

boottrace: Stop checking for failures from realloc(M_WAITOK)

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45852
---
 sys/kern/kern_boottrace.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/sys/kern/kern_boottrace.c b/sys/kern/kern_boottrace.c
index 1b097e7378ad..5516f3160587 100644
--- a/sys/kern/kern_boottrace.c
+++ b/sys/kern/kern_boottrace.c
@@ -561,9 +561,6 @@ boottrace_resize(u_int newsize)
}
rt.table = realloc(rt.table, newsize * sizeof(struct bt_event),
M_BOOTTRACE, M_WAITOK | M_ZERO);
-   if (rt.table == NULL)
-   return (ENOMEM);
-
rt.size = newsize;
boottrace_reset("boottrace_resize");
return (0);



git: 99e3bb555cb1 - main - subr_bus: Stop checking for failures from malloc(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=99e3bb555cb1ef5572de54be0ffed2aa6fc080cd

commit 99e3bb555cb1ef5572de54be0ffed2aa6fc080cd
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:17 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:17 +

subr_bus: Stop checking for failures from malloc(M_WAITOK)

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45852
---
 sys/kern/subr_bus.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c
index 71d04e483d4d..7fe46995ee54 100644
--- a/sys/kern/subr_bus.c
+++ b/sys/kern/subr_bus.c
@@ -5422,8 +5422,6 @@ sysctl_devices(SYSCTL_HANDLER_ARGS)
 * Populate the return item, careful not to overflow the buffer.
 */
udev = malloc(sizeof(*udev), M_BUS, M_WAITOK | M_ZERO);
-   if (udev == NULL)
-   return (ENOMEM);
udev->dv_handle = (uintptr_t)dev;
udev->dv_parent = (uintptr_t)dev->parent;
udev->dv_devflags = dev->devflags;



git: 8e6dd4185871 - main - ctl: Stop checking for failures from malloc(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=8e6dd4185871cd9b785869178ab2191a0d6c0b53

commit 8e6dd4185871cd9b785869178ab2191a0d6c0b53
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:18 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:18 +

ctl: Stop checking for failures from malloc(M_WAITOK)

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45852
---
 sys/cam/ctl/ctl.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c
index 845cffe77a5d..82420396aca1 100644
--- a/sys/cam/ctl/ctl.c
+++ b/sys/cam/ctl/ctl.c
@@ -2687,12 +2687,6 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, 
int flag,
}
 
entries = malloc(ooa_hdr->alloc_len, M_CTL, M_WAITOK | M_ZERO);
-   if (entries == NULL) {
-   printf("%s: could not allocate %d bytes for OOA "
-  "dump\n", __func__, ooa_hdr->alloc_len);
-   retval = ENOMEM;
-   break;
-   }
 
mtx_lock(&softc->ctl_lock);
if ((ooa_hdr->flags & CTL_OOA_FLAG_ALL_LUNS) == 0 &&



git: 3feb35dc465a - main - udf: Stop checking for failures from malloc(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=3feb35dc465a8247d70e50792680c230954ef1c1

commit 3feb35dc465a8247d70e50792680c230954ef1c1
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:18 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:18 +

udf: Stop checking for failures from malloc(M_WAITOK)

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45852
---
 sys/fs/udf/udf_vnops.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/sys/fs/udf/udf_vnops.c b/sys/fs/udf/udf_vnops.c
index f230ca0c72fa..98a779280690 100644
--- a/sys/fs/udf/udf_vnops.c
+++ b/sys/fs/udf/udf_vnops.c
@@ -800,8 +800,6 @@ udf_readdir(struct vop_readdir_args *a)
 */
ncookies = uio->uio_resid / 8;
cookies = malloc(sizeof(*cookies) * ncookies, M_TEMP, M_WAITOK);
-   if (cookies == NULL)
-   return (ENOMEM);
uiodir.ncookies = ncookies;
uiodir.cookies = cookies;
uiodir.acookies = 0;



git: 2a119886630b - main - altq: Stop checking for failures from malloc(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=2a119886630bb5fe8283e20db5acb7c0cdba31c3

commit 2a119886630bb5fe8283e20db5acb7c0cdba31c3
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:19 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:19 +

altq: Stop checking for failures from malloc(M_WAITOK)

While here, prefer malloc(M_ZERO) over bzero().

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45852
---
 sys/net/altq/altq_subr.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/sys/net/altq/altq_subr.c b/sys/net/altq/altq_subr.c
index 3ade724818dd..534841289611 100644
--- a/sys/net/altq/altq_subr.c
+++ b/sys/net/altq/altq_subr.c
@@ -1327,12 +1327,7 @@ acc_add_filter(classifier, filter, class, phandle)
return (EINVAL);
 #endif
 
-   afp = malloc(sizeof(struct acc_filter),
-  M_DEVBUF, M_WAITOK);
-   if (afp == NULL)
-   return (ENOMEM);
-   bzero(afp, sizeof(struct acc_filter));
-
+   afp = malloc(sizeof(*afp), M_DEVBUF, M_WAITOK | M_ZERO);
afp->f_filter = *filter;
afp->f_class = class;
 



git: 07b16b1e2aea - main - if_vlan: Stop checking for failures from malloc(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=07b16b1e2aeab0b30f68a013de31a4c322a61246

commit 07b16b1e2aeab0b30f68a013de31a4c322a61246
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:19 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:19 +

if_vlan: Stop checking for failures from malloc(M_WAITOK)

Fixes:  b08d611de835 fix vlan locking to permit sx acquisition in ioctl 
calls
MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45852
---
 sys/net/if_vlan.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c
index a30db9173383..774298d4a53a 100644
--- a/sys/net/if_vlan.c
+++ b/sys/net/if_vlan.c
@@ -509,11 +509,6 @@ vlan_growhash(struct ifvlantrunk *trunk, int howmuch)
return;
 
hash2 = malloc(sizeof(struct ifvlanhead) * n2, M_VLAN, M_WAITOK);
-   if (hash2 == NULL) {
-   printf("%s: out of memory -- hash size not changed\n",
-   __func__);
-   return; /* We can live with the old hash table */
-   }
for (j = 0; j < n2; j++)
CK_SLIST_INIT(&hash2[j]);
for (i = 0; i < n; i++)



git: 5b00557330b3 - main - pf: Stop checking for failures from malloc(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=5b00557330b3b69db84969e33f2e201288208dd9

commit 5b00557330b3b69db84969e33f2e201288208dd9
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:20 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:20 +

pf: Stop checking for failures from malloc(M_WAITOK)

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45852
---
 sys/netpfil/pf/pf_ioctl.c  | 32 
 sys/netpfil/pf/pf_syncookies.c |  3 ---
 2 files changed, 35 deletions(-)

diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c
index d22ffc2245cb..64086bf08871 100644
--- a/sys/netpfil/pf/pf_ioctl.c
+++ b/sys/netpfil/pf/pf_ioctl.c
@@ -2823,9 +2823,6 @@ pfioctl(struct cdev *dev, u_long cmd, caddr_t addr, int 
flags, struct thread *td
 
/* Copy the request in */
packed = malloc(nv->len, M_NVLIST, M_WAITOK);
-   if (packed == NULL)
-   ERROUT(ENOMEM);
-
error = copyin(nv->data, packed, nv->len);
if (error)
ERROUT(error);
@@ -2903,9 +2900,6 @@ DIOCGETETHRULES_error:
ERROUT(ENOMEM);
 
nvlpacked = malloc(nv->len, M_NVLIST, M_WAITOK);
-   if (nvlpacked == NULL)
-   ERROUT(ENOMEM);
-
error = copyin(nv->data, nvlpacked, nv->len);
if (error)
ERROUT(error);
@@ -3003,9 +2997,6 @@ DIOCGETETHRULE_error:
ERROUT(ENOMEM);
 
nvlpacked = malloc(nv->len, M_NVLIST, M_WAITOK);
-   if (nvlpacked == NULL)
-   ERROUT(ENOMEM);
-
error = copyin(nv->data, nvlpacked, nv->len);
if (error)
ERROUT(error);
@@ -3036,8 +3027,6 @@ DIOCGETETHRULE_error:
}
 
rule = malloc(sizeof(*rule), M_PFRULE, M_WAITOK);
-   if (rule == NULL)
-   ERROUT(ENOMEM);
rule->timestamp = NULL;
 
error = pf_nveth_rule_to_keth_rule(nvl, rule);
@@ -3136,9 +3125,6 @@ DIOCADDETHRULE_error:
ERROUT(ENOMEM);
 
nvlpacked = malloc(nv->len, M_NVLIST, M_WAITOK);
-   if (nvlpacked == NULL)
-   ERROUT(ENOMEM);
-
error = copyin(nv->data, nvlpacked, nv->len);
if (error)
ERROUT(error);
@@ -3214,9 +3200,6 @@ DIOCGETETHRULESETS_error:
ERROUT(ENOMEM);
 
nvlpacked = malloc(nv->len, M_NVLIST, M_WAITOK);
-   if (nvlpacked == NULL)
-   ERROUT(ENOMEM);
-
error = copyin(nv->data, nvlpacked, nv->len);
if (error)
ERROUT(error);
@@ -3409,9 +3392,6 @@ DIOCADDRULENV_error:
 
/* Copy the request in */
nvlpacked = malloc(nv->len, M_NVLIST, M_WAITOK);
-   if (nvlpacked == NULL)
-   ERROUT(ENOMEM);
-
error = copyin(nv->data, nvlpacked, nv->len);
if (error)
ERROUT(error);
@@ -6003,9 +5983,6 @@ pf_keepcounters(struct pfioc_nv *nv)
ERROUT(ENOMEM);
 
nvlpacked = malloc(nv->len, M_NVLIST, M_WAITOK);
-   if (nvlpacked == NULL)
-   ERROUT(ENOMEM);
-
error = copyin(nv->data, nvlpacked, nv->len);
if (error)
ERROUT(error);
@@ -6131,9 +6108,6 @@ pf_killstates_nv(struct pfioc_nv *nv)
ERROUT(ENOMEM);
 
nvlpacked = malloc(nv->len, M_NVLIST, M_WAITOK);
-   if (nvlpacked == NULL)
-   ERROUT(ENOMEM);
-
error = copyin(nv->data, nvlpacked, nv->len);
if (error)
ERROUT(error);
@@ -6192,9 +6166,6 @@ pf_clearstates_nv(struct pfioc_nv *nv)
ERROUT(ENOMEM);
 
nvlpacked = malloc(nv->len, M_NVLIST, M_WAITOK);
-   if (nvlpacked == NULL)
-   ERROUT(ENOMEM);
-
error = copyin(nv->data, nvlpacked, nv->len);
if (error)
ERROUT(error);
@@ -6253,9 +6224,6 @@ pf_getstate(struct pfioc_nv *nv)
ERROUT(ENOMEM);
 
nvlpacked = malloc(nv->len, M_NVLIST, M_WAITOK);
-   if (nvlpacked == NULL)
-   ERROUT(ENOMEM);
-
error = copyin(nv->data, nvlpacked, nv->len);
if (error)
ERROUT(error);
diff --git a/sys/netpfil/pf/pf_syncookies.c b/sys/netpfil/pf/pf_syncookies.c
index c5ee64c6aed0..538ab1dfd94c 100644
--- a/sys/netpfil/pf/pf_syncookies.c
+++ b/sys/netpfil/pf/pf_syncookies.c
@@ -201,9 +201,6 @@ pf_set_syncookies(struct pfioc_nv *nv)
return (ENOMEM);
 
nvlpacked = mallo

git: 6e50988cf822 - main - netsmb: Stop checking for failures from malloc(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=6e50988cf822f87a524b8da2fdc35b234078cc2f

commit 6e50988cf822f87a524b8da2fdc35b234078cc2f
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:20 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:20 +

netsmb: Stop checking for failures from malloc(M_WAITOK)

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45852
---
 sys/netsmb/smb_rq.c   | 4 
 sys/netsmb/smb_subr.c | 2 --
 2 files changed, 6 deletions(-)

diff --git a/sys/netsmb/smb_rq.c b/sys/netsmb/smb_rq.c
index a33598489aa1..b2642f1aaa6d 100644
--- a/sys/netsmb/smb_rq.c
+++ b/sys/netsmb/smb_rq.c
@@ -64,8 +64,6 @@ smb_rq_alloc(struct smb_connobj *layer, u_char cmd, struct 
smb_cred *scred,
int error;
 
rqp = malloc(sizeof(*rqp), M_SMBRQ, M_WAITOK);
-   if (rqp == NULL)
-   return ENOMEM;
error = smb_rq_init(rqp, layer, cmd, scred);
rqp->sr_flags |= SMBR_ALLOCED;
if (error) {
@@ -376,8 +374,6 @@ smb_t2_alloc(struct smb_connobj *layer, u_short setup, 
struct smb_cred *scred,
int error;
 
t2p = malloc(sizeof(*t2p), M_SMBRQ, M_WAITOK);
-   if (t2p == NULL)
-   return ENOMEM;
error = smb_t2_init(t2p, layer, setup, scred);
t2p->t2_flags |= SMBT2_ALLOCED;
if (error) {
diff --git a/sys/netsmb/smb_subr.c b/sys/netsmb/smb_subr.c
index fbb951a37cef..68469cf5cc35 100644
--- a/sys/netsmb/smb_subr.c
+++ b/sys/netsmb/smb_subr.c
@@ -149,8 +149,6 @@ smb_memdup(const void *umem, int len)
if (len > 8 * 1024)
return NULL;
p = malloc(len, M_SMBSTR, M_WAITOK);
-   if (p == NULL)
-   return NULL;
bcopy(umem, p, len);
return p;
 }



git: 7a720bf67d73 - main - xdr: Stop checking for failures from malloc(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=7a720bf67d73ba565a0a1130065f798870eb5faa

commit 7a720bf67d73ba565a0a1130065f798870eb5faa
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:20 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:20 +

xdr: Stop checking for failures from malloc(M_WAITOK)

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45852
---
 sys/xdr/xdr_sizeof.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/sys/xdr/xdr_sizeof.c b/sys/xdr/xdr_sizeof.c
index 6b4ee0352c9e..bcacf918f4fd 100644
--- a/sys/xdr/xdr_sizeof.c
+++ b/sys/xdr/xdr_sizeof.c
@@ -94,10 +94,7 @@ x_inline(XDR *xdrs, u_int len)
/* Free the earlier space and allocate new area */
if (xdrs->x_private)
free(xdrs->x_private, M_RPC);
-   if ((xdrs->x_private = (caddr_t) malloc(len, M_RPC, M_WAITOK)) 
== NULL) {
-   xdrs->x_base = 0;
-   return (NULL);
-   }
+   xdrs->x_private = malloc(len, M_RPC, M_WAITOK);
xdrs->x_base = (caddr_t)(uintptr_t) len;
xdrs->x_handy += len;
return ((int32_t *) xdrs->x_private);



git: 66c35a6675ff - main - krping: Stop checking for failures from malloc(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=66c35a6675ff987b52a2018871231658b1980a6c

commit 66c35a6675ff987b52a2018871231658b1980a6c
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:21 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:21 +

krping: Stop checking for failures from malloc(M_WAITOK)

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45852
---
 sys/contrib/rdma/krping/krping_dev.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/sys/contrib/rdma/krping/krping_dev.c 
b/sys/contrib/rdma/krping/krping_dev.c
index eea3c772ea4f..59aa19672443 100644
--- a/sys/contrib/rdma/krping/krping_dev.c
+++ b/sys/contrib/rdma/krping/krping_dev.c
@@ -174,12 +174,7 @@ krping_write(struct cdev *dev, struct uio *uio, int ioflag)
char *cp;
krping_t *krpingmsg;
 
-   krpingmsg = malloc(sizeof *krpingmsg, M_DEVBUF, M_WAITOK|M_ZERO);
-   if (!krpingmsg) {
-   uprintf("Could not malloc mem!\n");
-   return ENOMEM;
-   }
-
+   krpingmsg = malloc(sizeof *krpingmsg, M_DEVBUF, M_WAITOK | M_ZERO);
cp = krpingmsg->msg;
while (uio->uio_resid) {
amt = MIN(uio->uio_resid, remain);



git: 7bcb1228558b - main - LinuxKPI: 802.11: Stop checking for failures from malloc(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=7bcb1228558b4325fab39616e2e3b2573a9e7da6

commit 7bcb1228558b4325fab39616e2e3b2573a9e7da6
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:21 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:21 +

LinuxKPI: 802.11: Stop checking for failures from malloc(M_WAITOK)

As a consequence lkpi_ieee80211_ifalloc() now does not fail. Remove
unneeded NULL check.

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45852
---
 sys/compat/linuxkpi/common/src/linux_80211.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c 
b/sys/compat/linuxkpi/common/src/linux_80211.c
index b46e56133725..a2791d20a727 100644
--- a/sys/compat/linuxkpi/common/src/linux_80211.c
+++ b/sys/compat/linuxkpi/common/src/linux_80211.c
@@ -4401,8 +4401,6 @@ lkpi_ieee80211_ifalloc(void)
struct ieee80211com *ic;
 
ic = malloc(sizeof(*ic), M_LKPI80211, M_WAITOK | M_ZERO);
-   if (ic == NULL)
-   return (NULL);
 
/* Setting these happens later when we have device information. */
ic->ic_softc = NULL;
@@ -4454,10 +4452,6 @@ linuxkpi_ieee80211_alloc_hw(size_t priv_len, const 
struct ieee80211_ops *ops)
 
/* BSD Specific. */
lhw->ic = lkpi_ieee80211_ifalloc();
-   if (lhw->ic == NULL) {
-   ieee80211_free_hw(hw);
-   return (NULL);
-   }
 
IMPROVE();
 



git: aac6c41d4ba9 - main - tests: Stop checking for failures from malloc(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=aac6c41d4ba9b0a1aef561f6c4bfd284ab369ebf

commit aac6c41d4ba9b0a1aef561f6c4bfd284ab369ebf
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:21 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:21 +

tests: Stop checking for failures from malloc(M_WAITOK)

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45852
---
 sys/tests/framework/kern_testfrwk.c | 8 
 1 file changed, 8 deletions(-)

diff --git a/sys/tests/framework/kern_testfrwk.c 
b/sys/tests/framework/kern_testfrwk.c
index 19691f1febfc..949300290b9d 100644
--- a/sys/tests/framework/kern_testfrwk.c
+++ b/sys/tests/framework/kern_testfrwk.c
@@ -192,10 +192,6 @@ kerntest_execute(SYSCTL_HANDLER_ARGS)
}
/* Grab some memory */
kte = malloc(sizeof(struct kern_test_entry), M_KTFRWK, M_WAITOK);
-   if (kte == NULL) {
-   error = ENOMEM;
-   goto out;
-   }
KTFRWK_LOCK();
TAILQ_FOREACH(li, &kfrwk.kfrwk_testlist, next) {
if (strcmp(li->name, kt.name) == 0) {
@@ -244,10 +240,6 @@ kern_testframework_register(const char *name, kerntfunc 
func)
return (E2BIG);
}
te = malloc(sizeof(struct kern_test_list), M_KTFRWK, M_WAITOK);
-   if (te == NULL) {
-   error = ENOMEM;
-   goto out;
-   }
KTFRWK_LOCK();
/* First does it already exist? */
TAILQ_FOREACH(li, &kfrwk.kfrwk_testlist, next) {



git: fe6985ef87e1 - main - arm ti: Stop checking for failures from malloc(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=fe6985ef87e1aedf8e5c9b3b959c7dd54a03e2fe

commit fe6985ef87e1aedf8e5c9b3b959c7dd54a03e2fe
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:22 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:22 +

arm ti: Stop checking for failures from malloc(M_WAITOK)

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45852
---
 sys/arm/ti/ti_pruss.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/sys/arm/ti/ti_pruss.c b/sys/arm/ti/ti_pruss.c
index 85d075419fe8..b7a04f2cfb42 100644
--- a/sys/arm/ti/ti_pruss.c
+++ b/sys/arm/ti/ti_pruss.c
@@ -184,9 +184,6 @@ ti_pruss_irq_open(struct cdev *dev, int oflags, int 
devtype, struct thread *td)
sc = dev->si_drv1;
 
irqs = malloc(sizeof(struct ctl), M_DEVBUF, M_WAITOK);
-   if (!irqs)
-   return (ENOMEM);
-
irqs->cnt = sc->tstamps.ctl.cnt;
irqs->idx = sc->tstamps.ctl.idx;
 



git: 1d321c1907c2 - main - cmn600: Stop checking for failures from malloc/mallocarray(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=1d321c1907c210a33192ff5293f5c23554c96867

commit 1d321c1907c210a33192ff5293f5c23554c96867
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:22 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:22 +

cmn600: Stop checking for failures from malloc/mallocarray(M_WAITOK)

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45852
---
 sys/arm64/arm64/cmn600.c | 8 
 1 file changed, 8 deletions(-)

diff --git a/sys/arm64/arm64/cmn600.c b/sys/arm64/arm64/cmn600.c
index 4e3be8fee40e..530cdcdc3d06 100644
--- a/sys/arm64/arm64/cmn600.c
+++ b/sys/arm64/arm64/cmn600.c
@@ -332,9 +332,6 @@ cmn600_create_node(struct cmn600_softc *sc, off_t 
node_offset,
int i;
 
node = malloc(sizeof(struct cmn600_node), M_DEVBUF, M_WAITOK);
-   if (node == NULL)
-   return (NULL);
-
node->sc = sc;
node->nd_offset = node_offset;
node->nd_parent = parent;
@@ -399,8 +396,6 @@ cmn600_create_node(struct cmn600_softc *sc, off_t 
node_offset,
node->nd_children = (struct cmn600_node **)mallocarray(
node->nd_child_count, sizeof(struct cmn600_node *), M_DEVBUF,
M_WAITOK);
-   if (node->nd_children == NULL)
-   goto FAIL;
for (i = 0; i < node->nd_child_count; i++) {
val = node->nd_read8(node, child_offset + (i * 8));
node->nd_children[i] = cmn600_create_node(sc, val &
@@ -420,9 +415,6 @@ cmn600_create_node(struct cmn600_softc *sc, off_t 
node_offset,
break;
}
return (node);
-FAIL:
-   free(node, M_DEVBUF);
-   return (NULL);
 }
 
 static void



git: f75ceecad215 - main - smmu: Stop checking for failures from malloc(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=f75ceecad2157a0d3aca61a4893ab78f2dec21ee

commit f75ceecad2157a0d3aca61a4893ab78f2dec21ee
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:23 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:23 +

smmu: Stop checking for failures from malloc(M_WAITOK)

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45852
---
 sys/arm64/iommu/smmu.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/sys/arm64/iommu/smmu.c b/sys/arm64/iommu/smmu.c
index 93b0cbb7c8e4..a832f6a6ec70 100644
--- a/sys/arm64/iommu/smmu.c
+++ b/sys/arm64/iommu/smmu.c
@@ -960,10 +960,6 @@ smmu_init_strtab_2lvl(struct smmu_softc *sc)
sz = strtab->num_l1_entries * sizeof(struct l1_desc);
 
strtab->l1 = malloc(sz, M_SMMU, M_WAITOK | M_ZERO);
-   if (strtab->l1 == NULL) {
-   free(strtab->vaddr, M_SMMU);
-   return (ENOMEM);
-   }
 
reg = STRTAB_BASE_CFG_FMT_2LVL;
reg |= size << STRTAB_BASE_CFG_LOG2SIZE_S;



git: 00ae9c1be02e - main - al_eth: Stop checking for failures from malloc/buf_ring_alloc(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=00ae9c1be02e2db6ede1abd5b787bb9a3fbd76b0

commit 00ae9c1be02e2db6ede1abd5b787bb9a3fbd76b0
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:23 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:23 +

al_eth: Stop checking for failures from malloc/buf_ring_alloc(M_WAITOK)

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45852
---
 sys/dev/al_eth/al_eth.c | 18 --
 1 file changed, 18 deletions(-)

diff --git a/sys/dev/al_eth/al_eth.c b/sys/dev/al_eth/al_eth.c
index b8dd95e7ca58..e12c8dfcc281 100644
--- a/sys/dev/al_eth/al_eth.c
+++ b/sys/dev/al_eth/al_eth.c
@@ -2004,14 +2004,6 @@ al_eth_enable_msix(struct al_eth_adapter *adapter)
 
adapter->msix_entries = malloc(msix_vecs*sizeof(*adapter->msix_entries),
M_IFAL, M_ZERO | M_WAITOK);
-
-   if (adapter->msix_entries == NULL) {
-   device_printf_dbg(adapter->dev, "failed to allocate"
-   " msix_entries %d\n", msix_vecs);
-   rc = ENOMEM;
-   goto exit;
-   }
-
/* management vector (GROUP_A) @2*/
adapter->msix_entries[AL_ETH_MGMT_IRQ_IDX].entry = 2;
adapter->msix_entries[AL_ETH_MGMT_IRQ_IDX].vector = 0;
@@ -2299,9 +2291,6 @@ al_eth_setup_tx_resources(struct al_eth_adapter *adapter, 
int qid)
size = sizeof(struct al_eth_tx_buffer) * tx_ring->sw_count;
 
tx_ring->tx_buffer_info = malloc(size, M_IFAL, M_ZERO | M_WAITOK);
-   if (tx_ring->tx_buffer_info == NULL)
-   return (ENOMEM);
-
tx_ring->descs_size = tx_ring->hw_count * sizeof(union al_udma_desc);
q_params->size = tx_ring->hw_count;
 
@@ -2324,10 +2313,6 @@ al_eth_setup_tx_resources(struct al_eth_adapter 
*adapter, int qid)
mtx_init(&tx_ring->br_mtx, "AlRingMtx", NULL, MTX_DEF);
tx_ring->br = buf_ring_alloc(AL_BR_SIZE, M_DEVBUF, M_WAITOK,
&tx_ring->br_mtx);
-   if (tx_ring->br == NULL) {
-   device_printf(dev, "Critical Failure setting up buf ring\n");
-   return (ENOMEM);
-   }
 
/* Allocate taskqueues */
TASK_INIT(&tx_ring->enqueue_task, 0, al_eth_start_xmit, tx_ring);
@@ -2476,9 +2461,6 @@ al_eth_setup_rx_resources(struct al_eth_adapter *adapter, 
unsigned int qid)
size += 1;
 
rx_ring->rx_buffer_info = malloc(size, M_IFAL, M_ZERO | M_WAITOK);
-   if (rx_ring->rx_buffer_info == NULL)
-   return (ENOMEM);
-
rx_ring->descs_size = rx_ring->hw_count * sizeof(union al_udma_desc);
q_params->size = rx_ring->hw_count;
 



git: e06e2c840747 - main - altera: Stop checking for failures from malloc(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=e06e2c84074740a0087193d5929d09f1bc7e1c4b

commit e06e2c84074740a0087193d5929d09f1bc7e1c4b
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:24 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:24 +

altera: Stop checking for failures from malloc(M_WAITOK)

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45852
---
 sys/dev/altera/msgdma/msgdma.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/sys/dev/altera/msgdma/msgdma.c b/sys/dev/altera/msgdma/msgdma.c
index bb35d7315b6c..c5c75a5fb5e1 100644
--- a/sys/dev/altera/msgdma/msgdma.c
+++ b/sys/dev/altera/msgdma/msgdma.c
@@ -356,11 +356,6 @@ msgdma_desc_alloc(struct msgdma_softc *sc, struct 
msgdma_channel *chan,
/* Descriptors. */
chan->descs = malloc(nsegments * sizeof(struct msgdma_desc *),
M_DEVBUF, (M_WAITOK | M_ZERO));
-   if (chan->descs == NULL) {
-   device_printf(sc->dev,
-   "%s: Can't allocate memory.\n", __func__);
-   return (-1);
-   }
chan->dma_map = malloc(nsegments * sizeof(bus_dmamap_t),
M_DEVBUF, (M_WAITOK | M_ZERO));
chan->descs_phys = malloc(nsegments * sizeof(bus_dma_segment_t),



git: 3fdf587ab02f - main - ath(4): Stop checking for failures from malloc(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=3fdf587ab02f33018bd042094e3d0bd4169352ed

commit 3fdf587ab02f33018bd042094e3d0bd4169352ed
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:24 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:24 +

ath(4): Stop checking for failures from malloc(M_WAITOK)

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45852
---
 sys/dev/ath/if_ath_lna_div.c  | 6 --
 sys/dev/ath/if_ath_pci.c  | 5 -
 sys/dev/ath/if_ath_spectral.c | 7 ---
 3 files changed, 18 deletions(-)

diff --git a/sys/dev/ath/if_ath_lna_div.c b/sys/dev/ath/if_ath_lna_div.c
index 1b20591fc64e..0755bb667716 100644
--- a/sys/dev/ath/if_ath_lna_div.c
+++ b/sys/dev/ath/if_ath_lna_div.c
@@ -96,12 +96,6 @@ ath_lna_div_attach(struct ath_softc *sc)
 
ss = malloc(sizeof(struct if_ath_ant_comb_state),
M_TEMP, M_WAITOK | M_ZERO);
-   if (ss == NULL) {
-   device_printf(sc->sc_dev, "%s: failed to allocate\n",
-   __func__);
-   /* Don't fail at this point */
-   return (0);
-   }
 
/* Fetch the hardware configuration */
OS_MEMZERO(&div_ant_conf, sizeof(div_ant_conf));
diff --git a/sys/dev/ath/if_ath_pci.c b/sys/dev/ath/if_ath_pci.c
index 72f0a802aa5f..a242eab7a694 100644
--- a/sys/dev/ath/if_ath_pci.c
+++ b/sys/dev/ath/if_ath_pci.c
@@ -269,11 +269,6 @@ ath_pci_attach(device_t dev)
__func__, fw->data);
sc->sc_eepromdata =
malloc(fw->datasize, M_TEMP, M_WAITOK | M_ZERO);
-   if (! sc->sc_eepromdata) {
-   device_printf(dev, "%s: can't malloc eepromdata\n",
-   __func__);
-   goto bad4;
-   }
memcpy(sc->sc_eepromdata, fw->data, fw->datasize);
firmware_put(fw, 0);
}
diff --git a/sys/dev/ath/if_ath_spectral.c b/sys/dev/ath/if_ath_spectral.c
index 58f21b526e93..951d66605981 100644
--- a/sys/dev/ath/if_ath_spectral.c
+++ b/sys/dev/ath/if_ath_spectral.c
@@ -112,13 +112,6 @@ ath_spectral_attach(struct ath_softc *sc)
 
ss = malloc(sizeof(struct ath_spectral_state),
M_TEMP, M_WAITOK | M_ZERO);
-
-   if (ss == NULL) {
-   device_printf(sc->sc_dev, "%s: failed to alloc memory\n",
-   __func__);
-   return (-ENOMEM);
-   }
-
sc->sc_spectral = ss;
 
(void) ath_hal_spectral_get_config(sc->sc_ah, &ss->spectral_state);



git: ab0b996bddd9 - main - axgbe: Stop checking for failures from malloc(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=ab0b996bddd96300d56b7d2aa830e2479cdfa92b

commit ab0b996bddd96300d56b7d2aa830e2479cdfa92b
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:25 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:25 +

axgbe: Stop checking for failures from malloc(M_WAITOK)

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45852
---
 sys/dev/axgbe/xgbe-phy-v2.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/sys/dev/axgbe/xgbe-phy-v2.c b/sys/dev/axgbe/xgbe-phy-v2.c
index 5b39d61694e6..8c6069f83076 100644
--- a/sys/dev/axgbe/xgbe-phy-v2.c
+++ b/sys/dev/axgbe/xgbe-phy-v2.c
@@ -3771,8 +3771,6 @@ xgbe_phy_init(struct xgbe_prv_data *pdata)
return (ret);
 
phy_data = malloc(sizeof(*phy_data), M_AXGBE, M_WAITOK | M_ZERO);
-   if (!phy_data)
-   return (-ENOMEM);
pdata->phy_data = phy_data;
 
phy_data->port_mode = XP_GET_BITS(pdata->pp0, XP_PROP_0, PORT_MODE);



git: dcd387aaa5d4 - main - bnxt(4): Stop checking for failures from malloc(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=dcd387aaa5d4409a7e99376e0254029fce1a48a8

commit dcd387aaa5d4409a7e99376e0254029fce1a48a8
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:25 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:25 +

bnxt(4): Stop checking for failures from malloc(M_WAITOK)

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45852
---
 sys/dev/bnxt/bnxt_en/bnxt_mgmt.c | 18 --
 1 file changed, 18 deletions(-)

diff --git a/sys/dev/bnxt/bnxt_en/bnxt_mgmt.c b/sys/dev/bnxt/bnxt_en/bnxt_mgmt.c
index 2f82580352cb..72704c3db452 100644
--- a/sys/dev/bnxt/bnxt_en/bnxt_mgmt.c
+++ b/sys/dev/bnxt/bnxt_en/bnxt_mgmt.c
@@ -205,19 +205,7 @@ bnxt_mgmt_process_hwrm(struct cdev *dev, u_long cmd, 
caddr_t data,
}
 
req = malloc(msg_temp.len_req, M_BNXT, M_WAITOK | M_ZERO);
-   if(!req) {
-   device_printf(softc->dev, "%s:%d Memory allocation failed",
- __FUNCTION__, __LINE__);
-   return -ENOMEM;
-   }
-   
resp = malloc(msg_temp.len_resp, M_BNXT, M_WAITOK | M_ZERO);
-   if(!resp) {
-   device_printf(softc->dev, "%s:%d Memory allocation failed",
- __FUNCTION__, __LINE__);
-   ret = -ENOMEM;
-   goto end;
-   }
 
if (copyin((void *)msg_temp.usr_req, req, msg_temp.len_req)) {
device_printf(softc->dev, "%s:%d Failed to copy data from 
user\n",
@@ -237,12 +225,6 @@ bnxt_mgmt_process_hwrm(struct cdev *dev, u_long cmd, 
caddr_t data,
 (num_ind * sizeof(struct dma_info));
 
msg2 = malloc(size, M_BNXT, M_WAITOK | M_ZERO);
-   if(!msg2) {
-   device_printf(softc->dev, "%s:%d Memory allocation 
failed",
- __FUNCTION__, __LINE__);
-   ret = -ENOMEM;
-   goto end;
-   }
 
if (copyin((void *)mgmt_req.req.hreq, msg2, size)) { 
device_printf(softc->dev, "%s:%d Failed to copy"



git: bb51f7c8a48a - main - cxgb(4): Stop checking for failures from malloc/buf_ring_alloc(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=bb51f7c8a48a4cd5dfa67fefa81f3d5d199da92b

commit bb51f7c8a48a4cd5dfa67fefa81f3d5d199da92b
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:25 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:25 +

cxgb(4): Stop checking for failures from malloc/buf_ring_alloc(M_WAITOK)

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45852
---
 sys/dev/cxgb/cxgb_main.c | 4 +---
 sys/dev/cxgb/cxgb_sge.c  | 7 ++-
 2 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/sys/dev/cxgb/cxgb_main.c b/sys/dev/cxgb/cxgb_main.c
index 9bcdb86312c4..4d754aa8b1b7 100644
--- a/sys/dev/cxgb/cxgb_main.c
+++ b/sys/dev/cxgb/cxgb_main.c
@@ -2472,9 +2472,7 @@ set_eeprom(struct port_info *pi, const uint8_t *data, int 
len, int offset)
aligned_len = (len + (offset & 3) + 3) & ~3;
 
if (aligned_offset != offset || aligned_len != len) {
-   buf = malloc(aligned_len, M_DEVBUF, M_WAITOK|M_ZERO);   
   
-   if (!buf)
-   return (ENOMEM);
+   buf = malloc(aligned_len, M_DEVBUF, M_WAITOK | M_ZERO);
err = t3_seeprom_read(adapter, aligned_offset, (u32 *)buf);
if (!err && aligned_len > 4)
err = t3_seeprom_read(adapter,
diff --git a/sys/dev/cxgb/cxgb_sge.c b/sys/dev/cxgb/cxgb_sge.c
index 1b82f2ebcaae..52ffa5cdaffa 100644
--- a/sys/dev/cxgb/cxgb_sge.c
+++ b/sys/dev/cxgb/cxgb_sge.c
@@ -2419,11 +2419,8 @@ t3_sge_alloc_qset(adapter_t *sc, u_int id, int nports, 
int irq_vec_idx,
q->port = pi;
q->adap = sc;
 
-   if ((q->txq[TXQ_ETH].txq_mr = buf_ring_alloc(cxgb_txq_buf_ring_size,
-   M_DEVBUF, M_WAITOK, &q->lock)) == NULL) {
-   device_printf(sc->dev, "failed to allocate mbuf ring\n");
-   goto err;
-   }
+   q->txq[TXQ_ETH].txq_mr = buf_ring_alloc(cxgb_txq_buf_ring_size,
+   M_DEVBUF, M_WAITOK, &q->lock);
if ((q->txq[TXQ_ETH].txq_ifq = malloc(sizeof(struct ifaltq), M_DEVBUF,
M_NOWAIT | M_ZERO)) == NULL) {
device_printf(sc->dev, "failed to allocate ifq\n");



git: 955b380365af - main - cxgbe(4): Stop checking for failures from malloc/mb_alloc_ext_pgs(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=955b380365af174b3d35905b7b8afae97506a0bd

commit 955b380365af174b3d35905b7b8afae97506a0bd
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:26 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:26 +

cxgbe(4): Stop checking for failures from malloc/mb_alloc_ext_pgs(M_WAITOK)

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45852
---
 sys/dev/cxgbe/cxgbei/cxgbei.c | 3 ---
 sys/dev/cxgbe/tom/t4_cpl_io.c | 5 -
 2 files changed, 8 deletions(-)

diff --git a/sys/dev/cxgbe/cxgbei/cxgbei.c b/sys/dev/cxgbe/cxgbei/cxgbei.c
index 04454a98e247..ccca45f5f761 100644
--- a/sys/dev/cxgbe/cxgbei/cxgbei.c
+++ b/sys/dev/cxgbe/cxgbei/cxgbei.c
@@ -842,9 +842,6 @@ cxgbei_activate(struct adapter *sc)
 
/* per-adapter softc for iSCSI */
ci = malloc(sizeof(*ci), M_CXGBE, M_ZERO | M_WAITOK);
-   if (ci == NULL)
-   return (ENOMEM);
-
rc = cxgbei_init(sc, ci);
if (rc != 0) {
free(ci, M_CXGBE);
diff --git a/sys/dev/cxgbe/tom/t4_cpl_io.c b/sys/dev/cxgbe/tom/t4_cpl_io.c
index cb229d327386..0a40bbda3f3f 100644
--- a/sys/dev/cxgbe/tom/t4_cpl_io.c
+++ b/sys/dev/cxgbe/tom/t4_cpl_io.c
@@ -2127,11 +2127,6 @@ alloc_aiotx_mbuf(struct kaiocb *job, int len)
break;
 
m = mb_alloc_ext_pgs(M_WAITOK, aiotx_free_pgs);
-   if (m == NULL) {
-   vm_page_unhold_pages(pgs, npages);
-   break;
-   }
-
m->m_epg_1st_off = pgoff;
m->m_epg_npgs = npages;
if (npages == 1) {



git: 51971340bd3f - main - ena(4): Stop checking for failures from malloc(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=51971340bd3ff41591adbbfca68e9e753f6eb135

commit 51971340bd3ff41591adbbfca68e9e753f6eb135
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:26 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:26 +

ena(4): Stop checking for failures from malloc(M_WAITOK)

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45852
---
 sys/dev/ena/ena_rss.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/sys/dev/ena/ena_rss.c b/sys/dev/ena/ena_rss.c
index d90a7fbb253a..41fa9c62f94a 100644
--- a/sys/dev/ena/ena_rss.c
+++ b/sys/dev/ena/ena_rss.c
@@ -279,12 +279,9 @@ ena_rss_indir_init(struct ena_adapter *adapter)
struct ena_indir *indir = adapter->rss_indir;
int rc;
 
-   if (indir == NULL) {
+   if (indir == NULL)
adapter->rss_indir = indir = malloc(sizeof(struct ena_indir),
M_DEVBUF, M_WAITOK | M_ZERO);
-   if (indir == NULL)
-   return (ENOMEM);
-   }
 
rc = ena_rss_indir_get(adapter, indir->table);
if (rc != 0) {



git: 6dbf3aca4f5c - main - drm2: Stop checking for failures from malloc(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=6dbf3aca4f5c4f7287f186360c2391f2adfea8d6

commit 6dbf3aca4f5c4f7287f186360c2391f2adfea8d6
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:26 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:26 +

drm2: Stop checking for failures from malloc(M_WAITOK)

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45852
---
 sys/dev/drm2/drm_buffer.c | 30 -
 sys/dev/drm2/drm_crtc.c   | 45 +--
 sys/dev/drm2/ttm/ttm_object.c |  5 -
 3 files changed, 1 insertion(+), 79 deletions(-)

diff --git a/sys/dev/drm2/drm_buffer.c b/sys/dev/drm2/drm_buffer.c
index 8a674397262e..8069f2c8c4c6 100644
--- a/sys/dev/drm2/drm_buffer.c
+++ b/sys/dev/drm2/drm_buffer.c
@@ -50,45 +50,15 @@ int drm_buffer_alloc(struct drm_buffer **buf, int size)
 * variable sized */
*buf = malloc(sizeof(struct drm_buffer) + nr_pages*sizeof(char *),
DRM_MEM_DRIVER, M_ZERO | M_WAITOK);
-
-   if (*buf == NULL) {
-   DRM_ERROR("Failed to allocate drm buffer object to hold"
-   " %d bytes in %d pages.\n",
-   size, nr_pages);
-   return -ENOMEM;
-   }
-
(*buf)->size = size;
 
for (idx = 0; idx < nr_pages; ++idx) {
-
(*buf)->data[idx] =
malloc(min(PAGE_SIZE, size - idx * PAGE_SIZE),
DRM_MEM_DRIVER, M_WAITOK);
-
-
-   if ((*buf)->data[idx] == NULL) {
-   DRM_ERROR("Failed to allocate %dth page for drm"
-   " buffer with %d bytes and %d pages.\n",
-   idx + 1, size, nr_pages);
-   goto error_out;
-   }
-
}
 
return 0;
-
-error_out:
-
-   /* Only last element can be null pointer so check for it first. */
-   if ((*buf)->data[idx])
-   free((*buf)->data[idx], DRM_MEM_DRIVER);
-
-   for (--idx; idx >= 0; --idx)
-   free((*buf)->data[idx], DRM_MEM_DRIVER);
-
-   free(*buf, DRM_MEM_DRIVER);
-   return -ENOMEM;
 }
 EXPORT_SYMBOL(drm_buffer_alloc);
 
diff --git a/sys/dev/drm2/drm_crtc.c b/sys/dev/drm2/drm_crtc.c
index b9415082e7a1..a163c7455773 100644
--- a/sys/dev/drm2/drm_crtc.c
+++ b/sys/dev/drm2/drm_crtc.c
@@ -662,13 +662,6 @@ int drm_plane_init(struct drm_device *dev, struct 
drm_plane *plane,
plane->funcs = funcs;
plane->format_types = malloc(sizeof(uint32_t) * format_count,
DRM_MEM_KMS, M_WAITOK);
-   if (!plane->format_types) {
-   DRM_DEBUG_KMS("out of memory when allocating plane\n");
-   drm_mode_object_put(dev, &plane->base);
-   ret = -ENOMEM;
-   goto out;
-   }
-
memcpy(plane->format_types, formats, format_count * sizeof(uint32_t));
plane->format_count = format_count;
plane->possible_crtcs = possible_crtcs;
@@ -725,8 +718,6 @@ struct drm_display_mode *drm_mode_create(struct drm_device 
*dev)
 
nmode = malloc(sizeof(struct drm_display_mode), DRM_MEM_KMS,
M_WAITOK | M_ZERO);
-   if (!nmode)
-   return NULL;
 
if (drm_mode_object_get(dev, &nmode->base, DRM_MODE_OBJECT_MODE)) {
free(nmode, DRM_MEM_KMS);
@@ -1009,9 +1000,6 @@ int drm_mode_group_init(struct drm_device *dev, struct 
drm_mode_group *group)
 
group->id_list = malloc(total_objects * sizeof(uint32_t),
DRM_MEM_KMS, M_WAITOK | M_ZERO);
-   if (!group->id_list)
-   return -ENOMEM;
-
group->num_crtcs = 0;
group->num_connectors = 0;
group->num_encoders = 0;
@@ -1997,10 +1985,6 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
connector_set = malloc(crtc_req->count_connectors *
sizeof(struct drm_connector *),
DRM_MEM_KMS, M_WAITOK);
-   if (!connector_set) {
-   ret = -ENOMEM;
-   goto out;
-   }
 
for (i = 0; i < crtc_req->count_connectors; i++) {
set_connectors_ptr = (uint32_t __user *)(unsigned 
long)crtc_req->set_connectors_ptr;
@@ -2522,11 +2506,6 @@ int drm_mode_dirtyfb_ioctl(struct drm_device *dev,
}
clips = malloc(num_clips * sizeof(*clips), DRM_MEM_KMS,
M_WAITOK | M_ZERO);
-   if (!clips) {
-   ret = -ENOMEM;
-   goto out_err1;
-   }
-
ret = copy_from_user(clips, c

git: 48741f4ceca7 - main - etherswitch: Stop checking for failures from malloc(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=48741f4ceca71523aa1fa8da3bb78b184fad4aca

commit 48741f4ceca71523aa1fa8da3bb78b184fad4aca
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:27 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:27 +

etherswitch: Stop checking for failures from malloc(M_WAITOK)

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45852
---
 sys/dev/etherswitch/infineon/adm6996fc.c | 22 --
 sys/dev/etherswitch/micrel/ksz8995ma.c   | 22 --
 2 files changed, 8 insertions(+), 36 deletions(-)

diff --git a/sys/dev/etherswitch/infineon/adm6996fc.c 
b/sys/dev/etherswitch/infineon/adm6996fc.c
index 2c6c83a4388d..64f61df93db1 100644
--- a/sys/dev/etherswitch/infineon/adm6996fc.c
+++ b/sys/dev/etherswitch/infineon/adm6996fc.c
@@ -179,10 +179,6 @@ adm6996fc_attach_phys(struct adm6996fc_softc *sc)
if_initname(sc->ifp[port], name, port);
sc->miibus[port] = malloc(sizeof(device_t), M_ADM6996FC,
M_WAITOK | M_ZERO);
-   if (sc->miibus[port] == NULL) {
-   err = ENOMEM;
-   goto failed;
-   }
err = mii_attach(sc->sc_dev, sc->miibus[port], sc->ifp[port],
adm6996fc_ifmedia_upd, adm6996fc_ifmedia_sts, \
BMSR_DEFCAPMASK, phy, MII_OFFSET_ANY, 0);
@@ -255,12 +251,6 @@ adm6996fc_attach(device_t dev)
sc->portphy = malloc(sizeof(int) * sc->numports, M_ADM6996FC,
M_WAITOK | M_ZERO);
 
-   if (sc->ifp == NULL || sc->ifname == NULL || sc->miibus == NULL ||
-   sc->portphy == NULL) {
-   err = ENOMEM;
-   goto failed;
-   }
-
/*
 * Attach the PHYs and complete the bus enumeration.
 */
@@ -281,14 +271,10 @@ adm6996fc_attach(device_t dev)
return (0);
 
 failed:
-   if (sc->portphy != NULL)
-   free(sc->portphy, M_ADM6996FC);
-   if (sc->miibus != NULL)
-   free(sc->miibus, M_ADM6996FC);
-   if (sc->ifname != NULL)
-   free(sc->ifname, M_ADM6996FC);
-   if (sc->ifp != NULL)
-   free(sc->ifp, M_ADM6996FC);
+   free(sc->portphy, M_ADM6996FC);
+   free(sc->miibus, M_ADM6996FC);
+   free(sc->ifname, M_ADM6996FC);
+   free(sc->ifp, M_ADM6996FC);
 
return (err);
 }
diff --git a/sys/dev/etherswitch/micrel/ksz8995ma.c 
b/sys/dev/etherswitch/micrel/ksz8995ma.c
index e512a86202c6..ccd7dbffa9e9 100644
--- a/sys/dev/etherswitch/micrel/ksz8995ma.c
+++ b/sys/dev/etherswitch/micrel/ksz8995ma.c
@@ -225,10 +225,6 @@ ksz8995ma_attach_phys(struct ksz8995ma_softc *sc)
if_initname(sc->ifp[port], name, port);
sc->miibus[port] = malloc(sizeof(device_t), M_KSZ8995MA,
M_WAITOK | M_ZERO);
-   if (sc->miibus[port] == NULL) {
-   err = ENOMEM;
-   goto failed;
-   }
err = mii_attach(sc->sc_dev, sc->miibus[port], sc->ifp[port],
ksz8995ma_ifmedia_upd, ksz8995ma_ifmedia_sts, \
BMSR_DEFCAPMASK, phy, MII_OFFSET_ANY, 0);
@@ -305,12 +301,6 @@ ksz8995ma_attach(device_t dev)
sc->portphy = malloc(sizeof(int) * sc->numports, M_KSZ8995MA,
M_WAITOK | M_ZERO);
 
-   if (sc->ifp == NULL || sc->ifname == NULL || sc->miibus == NULL ||
-   sc->portphy == NULL) {
-   err = ENOMEM;
-   goto failed;
-   }
-
/*
 * Attach the PHYs and complete the bus enumeration.
 */
@@ -339,14 +329,10 @@ ksz8995ma_attach(device_t dev)
return (0);
 
 failed:
-   if (sc->portphy != NULL)
-   free(sc->portphy, M_KSZ8995MA);
-   if (sc->miibus != NULL)
-   free(sc->miibus, M_KSZ8995MA);
-   if (sc->ifname != NULL)
-   free(sc->ifname, M_KSZ8995MA);
-   if (sc->ifp != NULL)
-   free(sc->ifp, M_KSZ8995MA);
+   free(sc->portphy, M_KSZ8995MA);
+   free(sc->miibus, M_KSZ8995MA);
+   free(sc->ifname, M_KSZ8995MA);
+   free(sc->ifp, M_KSZ8995MA);
 
return (err);
 }



git: d1a89bd9b6eb - main - flexspi: Stop checking for failures from malloc(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=d1a89bd9b6eb1524902b619fa092c7d6de63e623

commit d1a89bd9b6eb1524902b619fa092c7d6de63e623
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:27 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:27 +

flexspi: Stop checking for failures from malloc(M_WAITOK)

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45852
---
 sys/dev/flash/flexspi/flex_spi.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/sys/dev/flash/flexspi/flex_spi.c b/sys/dev/flash/flexspi/flex_spi.c
index 766a1cfaa332..9382b237ee71 100644
--- a/sys/dev/flash/flexspi/flex_spi.c
+++ b/sys/dev/flash/flexspi/flex_spi.c
@@ -781,12 +781,6 @@ flex_spi_attach(device_t dev)
}
 
sc->buf = malloc(sc->erasesize, SECTOR_BUFFER, M_WAITOK);
-   if (sc->buf == NULL) {
-   device_printf(sc->dev, "Unable to set up allocate internal 
buffer\n");
-   flex_spi_detach(dev);
-   return (ENOMEM);
-   }
-
/* Move it to per-flash */
sc->disk = disk_alloc();
sc->disk->d_open = flex_spi_open;



git: 4d47c7ca7baa - main - fwip(4): Stop checking for failures from malloc(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=4d47c7ca7baa1ae76cc1fc72ec85b475f1efd41d

commit 4d47c7ca7baa1ae76cc1fc72ec85b475f1efd41d
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:28 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:28 +

fwip(4): Stop checking for failures from malloc(M_WAITOK)

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45852
---
 sys/dev/firewire/if_fwip.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/sys/dev/firewire/if_fwip.c b/sys/dev/firewire/if_fwip.c
index 6350ec9cb56e..41143e2e59d4 100644
--- a/sys/dev/firewire/if_fwip.c
+++ b/sys/dev/firewire/if_fwip.c
@@ -304,13 +304,9 @@ fwip_init(void *arg)
xferq->psize = MCLBYTES;
xferq->queued = 0;
xferq->buf = NULL;
-   xferq->bulkxfer = (struct fw_bulkxfer *) malloc(
+   xferq->bulkxfer = malloc(
sizeof(struct fw_bulkxfer) * xferq->bnchunk,
M_FWIP, M_WAITOK);
-   if (xferq->bulkxfer == NULL) {
-   printf("if_fwip: malloc failed\n");
-   return;
-   }
STAILQ_INIT(&xferq->stvalid);
STAILQ_INIT(&xferq->stfree);
STAILQ_INIT(&xferq->stdma);



git: 28e413a69983 - main - hpt27xx(4): Stop checking for failures from malloc(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=28e413a699838df6fa5b0504c9ceb92a515037d9

commit 28e413a699838df6fa5b0504c9ceb92a515037d9
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:28 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:28 +

hpt27xx(4): Stop checking for failures from malloc(M_WAITOK)

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45852
---
 sys/dev/hpt27xx/hpt27xx_osm_bsd.c | 19 +--
 1 file changed, 1 insertion(+), 18 deletions(-)

diff --git a/sys/dev/hpt27xx/hpt27xx_osm_bsd.c 
b/sys/dev/hpt27xx/hpt27xx_osm_bsd.c
index 225c91b44f21..e086a1554940 100644
--- a/sys/dev/hpt27xx/hpt27xx_osm_bsd.c
+++ b/sys/dev/hpt27xx/hpt27xx_osm_bsd.c
@@ -94,9 +94,6 @@ static int hpt_attach(device_t dev)
 
size = him->get_adapter_size(&pci_id);
hba->ldm_adapter.him_handle = malloc(size, M_DEVBUF, M_WAITOK);
-   if (!hba->ldm_adapter.him_handle)
-   return ENXIO;
-
hba->pcidev = dev;
hba->pciaddr.tree = 0;
hba->pciaddr.bus = pci_get_bus(dev);
@@ -114,10 +111,6 @@ static int hpt_attach(device_t dev)
if (!ldm_register_adapter(&hba->ldm_adapter)) {
size = ldm_get_vbus_size();
vbus_ext = malloc(sizeof(VBUS_EXT) + size, M_DEVBUF, M_WAITOK);
-   if (!vbus_ext) {
-   free(hba->ldm_adapter.him_handle, M_DEVBUF);
-   return ENXIO;
-   }
memset(vbus_ext, 0, sizeof(VBUS_EXT));
vbus_ext->ext_type = EXT_TYPE_VBUS;
ldm_create_vbus((PVBUS)vbus_ext->vbus, vbus_ext);
@@ -168,7 +161,6 @@ static int hpt_alloc_mem(PVBUS_EXT vbus_ext)
f->tag, f->count, f->size, f->count*f->size));
for (i=0; icount; i++) {
p = (void **)malloc(f->size, M_DEVBUF, M_WAITOK);
-   if (!p) return (ENXIO);
*p = f->head;
f->head = p;
}
@@ -1109,10 +1101,6 @@ static void hpt_final_init(void *dummy)
 
for (i=0; ivbus_ext = vbus_ext;
ext->next = vbus_ext->cmdext_list;
vbus_ext->cmdext_list = ext;
@@ -1327,18 +1315,13 @@ static int hpt_ioctl(struct cdev *dev, u_long cmd, 
caddr_t data, int fflag, stru
 
if (ioctl_args.nInBufferSize) {
ioctl_args.lpInBuffer = 
malloc(ioctl_args.nInBufferSize, M_DEVBUF, M_WAITOK);
-   if (!ioctl_args.lpInBuffer)
-   goto invalid;
if (copyin((void*)piop->lpInBuffer,
ioctl_args.lpInBuffer, 
piop->nInBufferSize))
goto invalid;
}

-   if (ioctl_args.nOutBufferSize) {
+   if (ioctl_args.nOutBufferSize)
ioctl_args.lpOutBuffer = 
malloc(ioctl_args.nOutBufferSize, M_DEVBUF, M_WAITOK | M_ZERO);
-   if (!ioctl_args.lpOutBuffer)
-   goto invalid;
-   }
 
hpt_do_ioctl(&ioctl_args);
 



git: a3ec5d3ee757 - main - hptnr(4): Stop checking for failures from malloc(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=a3ec5d3ee7579a26790a86ca4c074512946ab964

commit a3ec5d3ee7579a26790a86ca4c074512946ab964
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:29 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:29 +

hptnr(4): Stop checking for failures from malloc(M_WAITOK)

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45852
---
 sys/dev/hptnr/hptnr_osm_bsd.c | 14 ++
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/sys/dev/hptnr/hptnr_osm_bsd.c b/sys/dev/hptnr/hptnr_osm_bsd.c
index a8ac77c5ad5a..7426873964fb 100644
--- a/sys/dev/hptnr/hptnr_osm_bsd.c
+++ b/sys/dev/hptnr/hptnr_osm_bsd.c
@@ -165,7 +165,6 @@ static int hpt_alloc_mem(PVBUS_EXT vbus_ext)
f->tag, f->count, f->size, f->count*f->size));
for (i=0; icount; i++) {
p = (void **)malloc(f->size, M_DEVBUF, M_WAITOK);
-   if (!p) return (ENXIO);
*p = f->head;
f->head = p;
}
@@ -1389,10 +1388,6 @@ static void hpt_final_init(void *dummy)
 
for (i=0; ivbus_ext = vbus_ext;
ext->next = vbus_ext->cmdext_list;
vbus_ext->cmdext_list = ext;
@@ -1610,19 +1605,14 @@ static int hpt_ioctl(struct cdev *dev, u_long cmd, 
caddr_t data, int fflag, stru
 
if (ioctl_args.nInBufferSize) {
ioctl_args.lpInBuffer = 
malloc(ioctl_args.nInBufferSize, M_DEVBUF, M_WAITOK);
-   if (!ioctl_args.lpInBuffer)
-   goto invalid;
if (copyin((void*)piop->lpInBuffer,
ioctl_args.lpInBuffer, 
piop->nInBufferSize))
goto invalid;
}

-   if (ioctl_args.nOutBufferSize) {
+   if (ioctl_args.nOutBufferSize)
ioctl_args.lpOutBuffer = 
malloc(ioctl_args.nOutBufferSize, M_DEVBUF, M_WAITOK | M_ZERO);
-   if (!ioctl_args.lpOutBuffer)
-   goto invalid;
-   }
-   
+
hpt_do_ioctl(&ioctl_args);

if (ioctl_args.result==HPT_IOCTL_RESULT_OK) {



git: 92b0370ec65d - main - hptrr(4): Stop checking for failures from malloc(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=92b0370ec65d5287a1deec84fd513e320a8da736

commit 92b0370ec65d5287a1deec84fd513e320a8da736
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:29 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:29 +

hptrr(4): Stop checking for failures from malloc(M_WAITOK)

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45852
---
 sys/dev/hptrr/hptrr_osm_bsd.c | 13 ++---
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/sys/dev/hptrr/hptrr_osm_bsd.c b/sys/dev/hptrr/hptrr_osm_bsd.c
index 68e9af3aff02..42866c1d4297 100644
--- a/sys/dev/hptrr/hptrr_osm_bsd.c
+++ b/sys/dev/hptrr/hptrr_osm_bsd.c
@@ -1032,10 +1032,6 @@ static void hpt_final_init(void *dummy)
 
for (i=0; ivbus_ext = vbus_ext;
ext->next = vbus_ext->cmdext_list;
vbus_ext->cmdext_list = ext;
@@ -1252,19 +1248,14 @@ static int hpt_ioctl(struct cdev *dev, u_long cmd, 
caddr_t data, int fflag, stru
 
if (ioctl_args.nInBufferSize) {
ioctl_args.lpInBuffer = 
malloc(ioctl_args.nInBufferSize, M_DEVBUF, M_WAITOK);
-   if (!ioctl_args.lpInBuffer)
-   goto invalid;
if (copyin((void*)piop->lpInBuffer,
ioctl_args.lpInBuffer, 
piop->nInBufferSize))
goto invalid;
}

-   if (ioctl_args.nOutBufferSize) {
+   if (ioctl_args.nOutBufferSize)
ioctl_args.lpOutBuffer = 
malloc(ioctl_args.nOutBufferSize, M_DEVBUF, M_WAITOK | M_ZERO);
-   if (!ioctl_args.lpOutBuffer)
-   goto invalid;
-   }
-   
+
hpt_do_ioctl(&ioctl_args);

if (ioctl_args.result==HPT_IOCTL_RESULT_OK) {



git: 40a6bbc42841 - main - iser(4): Stop checking for failures from malloc(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=40a6bbc4284111790d9240f8a24ef11a9a9ecb07

commit 40a6bbc4284111790d9240f8a24ef11a9a9ecb07
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:30 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:30 +

iser(4): Stop checking for failures from malloc(M_WAITOK)

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45852
---
 sys/dev/iser/iser_verbs.c | 11 ---
 1 file changed, 11 deletions(-)

diff --git a/sys/dev/iser/iser_verbs.c b/sys/dev/iser/iser_verbs.c
index f5f057b961ef..f0c7e524ccf0 100644
--- a/sys/dev/iser/iser_verbs.c
+++ b/sys/dev/iser/iser_verbs.c
@@ -212,8 +212,6 @@ iser_create_device_ib_res(struct iser_device *device)
 
device->comps = malloc(device->comps_used * sizeof(*device->comps),
M_ISER_VERBS, M_WAITOK | M_ZERO);
-   if (!device->comps)
-   goto comps_err;
 
max_cqe = min(ISER_MAX_CQ_LEN, ib_dev->attrs.max_cqe);
 
@@ -280,7 +278,6 @@ cq_err:
ib_dealloc_pd(device->pd);
 pd_err:
free(device->comps, M_ISER_VERBS);
-comps_err:
ISER_ERR("failed to allocate an IB resource");
return (1);
 }
@@ -343,11 +340,6 @@ iser_create_fastreg_desc(struct ib_device *ib_device, 
struct ib_pd *pd)
int ret;
 
desc = malloc(sizeof(*desc), M_ISER_VERBS, M_WAITOK | M_ZERO);
-   if (!desc) {
-   ISER_ERR("Failed to allocate a new fastreg descriptor");
-   return (NULL);
-   }
-
ret = iser_alloc_reg_res(ib_device, pd, &desc->rsc);
if (ret) {
ISER_ERR("failed to allocate reg_resources");
@@ -509,9 +501,6 @@ iser_device_find_by_ib_device(struct rdma_cm_id *cma_id)
goto inc_refcnt;
 
device = malloc(sizeof *device, M_ISER_VERBS, M_WAITOK | M_ZERO);
-   if (device == NULL)
-   goto out;
-
/* assign this device to the device */
device->ib_device = cma_id->device;
/* init the device and link it into ig device list */



git: 5f97656fa334 - main - ice(4): Stop checking for failures from malloc(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=5f97656fa334b494d70866cb1bfff406d3efd92d

commit 5f97656fa334b494d70866cb1bfff406d3efd92d
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:29 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:29 +

ice(4): Stop checking for failures from malloc(M_WAITOK)

As a consequence now ice_alloc_vsi_qmap() does not fail. Remove unneeded
error checks.

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45852
---
 sys/dev/ice/ice_lib.c  | 24 +++-
 sys/dev/ice/ice_lib.h  |  2 +-
 sys/dev/ice/if_ice_iflib.c | 13 ++---
 3 files changed, 6 insertions(+), 33 deletions(-)

diff --git a/sys/dev/ice/ice_lib.c b/sys/dev/ice/ice_lib.c
index 659412450fce..7077859cc877 100644
--- a/sys/dev/ice/ice_lib.c
+++ b/sys/dev/ice/ice_lib.c
@@ -426,31 +426,21 @@ ice_setup_pf_vsi(struct ice_softc *sc)
  * all queues for this VSI are not yet assigned an index and thus,
  * not ready for use.
  *
- * Returns an error code on failure.
  */
-int
+void
 ice_alloc_vsi_qmap(struct ice_vsi *vsi, const int max_tx_queues,
   const int max_rx_queues)
 {
-   struct ice_softc *sc = vsi->sc;
int i;
 
MPASS(max_tx_queues > 0);
MPASS(max_rx_queues > 0);
 
/* Allocate Tx queue mapping memory */
-   if (!(vsi->tx_qmap =
- (u16 *) malloc(sizeof(u16) * max_tx_queues, M_ICE, M_WAITOK))) {
-   device_printf(sc->dev, "Unable to allocate Tx qmap memory\n");
-   return (ENOMEM);
-   }
+   vsi->tx_qmap = malloc(sizeof(u16) * max_tx_queues, M_ICE, M_WAITOK);
 
/* Allocate Rx queue mapping memory */
-   if (!(vsi->rx_qmap =
- (u16 *) malloc(sizeof(u16) * max_rx_queues, M_ICE, M_WAITOK))) {
-   device_printf(sc->dev, "Unable to allocate Rx qmap memory\n");
-   goto free_tx_qmap;
-   }
+   vsi->rx_qmap = malloc(sizeof(u16) * max_rx_queues, M_ICE, M_WAITOK);
 
/* Mark every queue map as invalid to start with */
for (i = 0; i < max_tx_queues; i++) {
@@ -459,14 +449,6 @@ ice_alloc_vsi_qmap(struct ice_vsi *vsi, const int 
max_tx_queues,
for (i = 0; i < max_rx_queues; i++) {
vsi->rx_qmap[i] = ICE_INVALID_RES_IDX;
}
-
-   return 0;
-
-free_tx_qmap:
-   free(vsi->tx_qmap, M_ICE);
-   vsi->tx_qmap = NULL;
-
-   return (ENOMEM);
 }
 
 /**
diff --git a/sys/dev/ice/ice_lib.h b/sys/dev/ice/ice_lib.h
index cfd848d370bb..6c010cffc0fd 100644
--- a/sys/dev/ice/ice_lib.h
+++ b/sys/dev/ice/ice_lib.h
@@ -830,7 +830,7 @@ void ice_free_bar(device_t dev, struct ice_bar_info *bar);
 void ice_set_ctrlq_len(struct ice_hw *hw);
 void ice_release_vsi(struct ice_vsi *vsi);
 struct ice_vsi *ice_alloc_vsi(struct ice_softc *sc, enum ice_vsi_type type);
-int  ice_alloc_vsi_qmap(struct ice_vsi *vsi, const int max_tx_queues,
+void ice_alloc_vsi_qmap(struct ice_vsi *vsi, const int max_tx_queues,
   const int max_rx_queues);
 void ice_free_vsi_qmaps(struct ice_vsi *vsi);
 int  ice_initialize_vsi(struct ice_vsi *vsi);
diff --git a/sys/dev/ice/if_ice_iflib.c b/sys/dev/ice/if_ice_iflib.c
index 4e451bf3fb55..3de79787f6e8 100644
--- a/sys/dev/ice/if_ice_iflib.c
+++ b/sys/dev/ice/if_ice_iflib.c
@@ -631,12 +631,8 @@ reinit_hw:
 */
ice_setup_pf_vsi(sc);
 
-   err = ice_alloc_vsi_qmap(&sc->pf_vsi, scctx->isc_ntxqsets_max,
+   ice_alloc_vsi_qmap(&sc->pf_vsi, scctx->isc_ntxqsets_max,
scctx->isc_nrxqsets_max);
-   if (err) {
-   device_printf(dev, "Unable to allocate VSI Queue maps\n");
-   goto free_main_vsi;
-   }
 
/* Allocate MSI-X vectors (due to isc_flags IFLIB_SKIP_MSIX) */
err = ice_allocate_msix(sc);
@@ -3518,12 +3514,7 @@ ice_setup_mirror_vsi(struct ice_mirr_if *mif)
mif->vsi = vsi;
 
/* Reserve VSI queue allocation from PF queues */
-   ret = ice_alloc_vsi_qmap(vsi, ICE_DEFAULT_VF_QUEUES, 
ICE_DEFAULT_VF_QUEUES);
-   if (ret) {
-   device_printf(dev, "%s: Unable to allocate mirror VSI queue 
maps (%d queues): %s\n",
-   __func__, ICE_DEFAULT_VF_QUEUES, ice_err_str(ret));
-   goto release_vsi;
-   }
+   ice_alloc_vsi_qmap(vsi, ICE_DEFAULT_VF_QUEUES, ICE_DEFAULT_VF_QUEUES);
vsi->num_tx_queues = vsi->num_rx_queues = ICE_DEFAULT_VF_QUEUES;
 
/* Assign Tx queues from PF space */



git: 1dc7a7b74b5a - main - mana: Stop checking for failures from malloc/mallocarray/buf_ring_alloc(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=1dc7a7b74b5ad37ff7c8dc22f1a710460a5f1dcd

commit 1dc7a7b74b5ad37ff7c8dc22f1a710460a5f1dcd
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:30 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:30 +

mana: Stop checking for failures from 
malloc/mallocarray/buf_ring_alloc(M_WAITOK)

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45852
---
 sys/dev/mana/gdma_main.c  | 19 ---
 sys/dev/mana/hw_channel.c | 17 -
 sys/dev/mana/mana_en.c| 41 -
 3 files changed, 77 deletions(-)

diff --git a/sys/dev/mana/gdma_main.c b/sys/dev/mana/gdma_main.c
index 6f3e182ba1eb..13f2617ad7d4 100644
--- a/sys/dev/mana/gdma_main.c
+++ b/sys/dev/mana/gdma_main.c
@@ -868,9 +868,6 @@ int mana_gd_create_hwc_queue(struct gdma_dev *gd,
int err;
 
queue = malloc(sizeof(*queue), M_DEVBUF, M_WAITOK | M_ZERO);
-   if (!queue)
-   return ENOMEM;
-
gmi = &queue->mem_info;
err = mana_gd_alloc_memory(gc, spec->queue_size, gmi);
if (err)
@@ -962,9 +959,6 @@ mana_gd_create_dma_region(struct gdma_dev *gd,
}
 
req = malloc(req_msg_size, M_DEVBUF, M_WAITOK | M_ZERO);
-   if (!req)
-   return ENOMEM;
-
mana_gd_init_req_hdr(&req->hdr, GDMA_CREATE_DMA_REGION,
req_msg_size, sizeof(resp));
req->length = length;
@@ -1008,9 +1002,6 @@ mana_gd_create_mana_eq(struct gdma_dev *gd,
return EINVAL;
 
queue = malloc(sizeof(*queue),  M_DEVBUF, M_WAITOK | M_ZERO);
-   if (!queue)
-   return ENOMEM;
-
gmi = &queue->mem_info;
err = mana_gd_alloc_memory(gc, spec->queue_size, gmi);
if (err)
@@ -1056,9 +1047,6 @@ int mana_gd_create_mana_wq_cq(struct gdma_dev *gd,
return EINVAL;
 
queue = malloc(sizeof(*queue), M_DEVBUF, M_WAITOK | M_ZERO);
-   if (!queue)
-   return ENOMEM;
-
gmi = &queue->mem_info;
err = mana_gd_alloc_memory(gc, spec->queue_size, gmi);
if (err)
@@ -1480,9 +1468,6 @@ mana_gd_alloc_res_map(uint32_t res_avail,
 
r->map =
malloc(n * sizeof(unsigned long), M_DEVBUF, M_WAITOK | M_ZERO);
-   if (!r->map)
-   return ENOMEM;
-
r->size = res_avail;
mtx_init(&r->lock_spin, lock_name, NULL, MTX_SPIN);
 
@@ -1616,10 +1601,6 @@ mana_gd_setup_irqs(device_t dev)
 
gc->irq_contexts = malloc(nvec * sizeof(struct gdma_irq_context),
M_DEVBUF, M_WAITOK | M_ZERO);
-   if (!gc->irq_contexts) {
-   rc = ENOMEM;
-   goto err_setup_irq_release;
-   }
 
for (i = 0; i < nvec; i++) {
gic = &gc->irq_contexts[i];
diff --git a/sys/dev/mana/hw_channel.c b/sys/dev/mana/hw_channel.c
index 7a40a28894fb..5904389596a3 100644
--- a/sys/dev/mana/hw_channel.c
+++ b/sys/dev/mana/hw_channel.c
@@ -416,8 +416,6 @@ mana_hwc_create_cq(struct hw_channel_context *hwc,
cq_size = MINIMUM_SUPPORTED_PAGE_SIZE;
 
hwc_cq = malloc(sizeof(*hwc_cq), M_DEVBUF, M_WAITOK | M_ZERO);
-   if (!hwc_cq)
-   return ENOMEM;
 
err = mana_hwc_create_gdma_eq(hwc, eq_size, ctx, callback, &eq);
if (err) {
@@ -438,10 +436,6 @@ mana_hwc_create_cq(struct hw_channel_context *hwc,
 
comp_buf = mallocarray(q_depth, sizeof(struct gdma_comp),
M_DEVBUF, M_WAITOK | M_ZERO);
-   if (!comp_buf) {
-   err = ENOMEM;
-   goto out;
-   }
 
hwc_cq->hwc = hwc;
hwc_cq->comp_buf = comp_buf;
@@ -476,8 +470,6 @@ mana_hwc_alloc_dma_buf(struct hw_channel_context *hwc, 
uint16_t q_depth,
dma_buf = malloc(sizeof(*dma_buf) +
q_depth * sizeof(struct hwc_work_request),
M_DEVBUF, M_WAITOK | M_ZERO);
-   if (!dma_buf)
-   return ENOMEM;
 
dma_buf->num_reqs = q_depth;
 
@@ -560,8 +552,6 @@ mana_hwc_create_wq(struct hw_channel_context *hwc,
queue_size = MINIMUM_SUPPORTED_PAGE_SIZE;
 
hwc_wq = malloc(sizeof(*hwc_wq), M_DEVBUF, M_WAITOK | M_ZERO);
-   if (!hwc_wq)
-   return ENOMEM;
 
err = mana_hwc_create_gdma_wq(hwc, q_type, queue_size, &queue);
if (err)
@@ -669,8 +659,6 @@ mana_hwc_test_channel(struct hw_channel_context *hwc, 
uint16_t q_depth,
 
ctx = malloc(q_depth * sizeof(struct hwc_caller_ctx),
M_DEVBUF, M_WAITOK | M_ZERO);
-   if (!ctx)
-   return ENOMEM;
 
for (i = 0; i < q_depth; ++i)
init_completion(&ctx[i].comp_event);
@@ -719,9 +707,6 @@ mana_hwc_establish_channel(struct gdma_context *gc, 
uint16_t *q_depth,
 
gc->cq_table = malloc(gc->max_num_

git: 701308ef404f - main - mfi(4): Stop checking for failures from malloc(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=701308ef404f552034f8c3e3e912b41bfef28ee6

commit 701308ef404f552034f8c3e3e912b41bfef28ee6
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:31 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:31 +

mfi(4): Stop checking for failures from malloc(M_WAITOK)

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45852
---
 sys/dev/mfi/mfi.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/sys/dev/mfi/mfi.c b/sys/dev/mfi/mfi.c
index 2885bd695f50..328118ef9596 100644
--- a/sys/dev/mfi/mfi.c
+++ b/sys/dev/mfi/mfi.c
@@ -3633,11 +3633,8 @@ out:
mfi_aen_entry = malloc(sizeof(struct mfi_aen), M_MFIBUF,
M_WAITOK);
mtx_lock(&sc->mfi_io_lock);
-   if (mfi_aen_entry != NULL) {
-   mfi_aen_entry->p = curproc;
-   TAILQ_INSERT_TAIL(&sc->mfi_aen_pids, mfi_aen_entry,
-   aen_link);
-   }
+   mfi_aen_entry->p = curproc;
+   TAILQ_INSERT_TAIL(&sc->mfi_aen_pids, mfi_aen_entry, aen_link);
error = mfi_aen_register(sc, l_aen.laen_seq_num,
l_aen.laen_class_locale);
 



git: 556cd18fb076 - main - mlx(4): Stop checking for failures from malloc(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=556cd18fb07604e3442819b221afb2a19b924dbd

commit 556cd18fb07604e3442819b221afb2a19b924dbd
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:31 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:31 +

mlx(4): Stop checking for failures from malloc(M_WAITOK)

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45852
---
 sys/dev/mlx/mlx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/dev/mlx/mlx.c b/sys/dev/mlx/mlx.c
index 8e86a00222da..7e4cb443894a 100644
--- a/sys/dev/mlx/mlx.c
+++ b/sys/dev/mlx/mlx.c
@@ -2075,8 +2075,8 @@ mlx_user_command(struct mlx_softc *sc, struct 
mlx_usercommand *mu)
goto out;
}
MLX_IO_UNLOCK(sc);
-   if (((kbuf = malloc(mu->mu_datasize, M_DEVBUF, M_WAITOK)) == NULL) ||
-   (error = copyin(mu->mu_buf, kbuf, mu->mu_datasize))) {
+   kbuf = malloc(mu->mu_datasize, M_DEVBUF, M_WAITOK);
+   if ((error = copyin(mu->mu_buf, kbuf, mu->mu_datasize))) {
MLX_IO_LOCK(sc);
goto out;
}



git: a38d9ad47312 - main - mrsas(4): Stop checking for failures from malloc(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=a38d9ad473123dca86108651ba10740055720777

commit a38d9ad473123dca86108651ba10740055720777
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:32 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:32 +

mrsas(4): Stop checking for failures from malloc(M_WAITOK)

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45852
---
 sys/dev/mrsas/mrsas_ioctl.c | 13 -
 1 file changed, 13 deletions(-)

diff --git a/sys/dev/mrsas/mrsas_ioctl.c b/sys/dev/mrsas/mrsas_ioctl.c
index 74eacfbeb9fa..8a85544604a4 100644
--- a/sys/dev/mrsas/mrsas_ioctl.c
+++ b/sys/dev/mrsas/mrsas_ioctl.c
@@ -462,13 +462,6 @@ mrsas_user_command(struct mrsas_softc *sc, struct 
mfi_ioc_passthru *ioc)
kern_sge[0].length = 0;
} else {
ioctl_temp_data_mem = malloc(ioc->buf_size, M_MRSAS, M_WAITOK);
-   if (ioctl_temp_data_mem == NULL) {
-   device_printf(sc->mrsas_dev, "Could not allocate "
-   "%d memory for temporary passthrough ioctl\n",
-   ioc->buf_size);
-   ret = ENOMEM;
-   goto out;
-   }
 
/* Copy in data from user space */
ret = copyin(ioc->buf, ioctl_temp_data_mem, ioc->buf_size);
@@ -483,12 +476,6 @@ mrsas_user_command(struct mrsas_softc *sc, struct 
mfi_ioc_passthru *ioc)
 */
passcmd = malloc(sizeof(struct mrsas_passthru_cmd), M_MRSAS,
M_WAITOK);
-   if (passcmd == NULL) {
-   device_printf(sc->mrsas_dev, "Could not allocate "
-   "memory for temporary passthrough cb struct\n");
-   ret = ENOMEM;
-   goto out;
-   }
passcmd->complete = 0;
passcmd->sc = sc;
passcmd->cmd = cmd;



git: 849f9ac370bd - main - mpi3mr(4): Stop checking for failures from malloc(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=849f9ac370bd66993ce5cc6fca0d2ef9bd03c2c9

commit 849f9ac370bd66993ce5cc6fca0d2ef9bd03c2c9
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:31 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:31 +

mpi3mr(4): Stop checking for failures from malloc(M_WAITOK)

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45852
---
 sys/dev/mpi3mr/mpi3mr_cam.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/sys/dev/mpi3mr/mpi3mr_cam.c b/sys/dev/mpi3mr/mpi3mr_cam.c
index e00d61073d96..b4999e204ab7 100644
--- a/sys/dev/mpi3mr/mpi3mr_cam.c
+++ b/sys/dev/mpi3mr/mpi3mr_cam.c
@@ -2098,12 +2098,6 @@ mpi3mr_cam_attach(struct mpi3mr_softc *sc)
mpi3mr_dprint(sc, MPI3MR_XINFO, "Starting CAM Attach\n");
 
cam_sc = malloc(sizeof(struct mpi3mr_cam_softc), M_MPI3MR, 
M_WAITOK|M_ZERO);
-   if (!cam_sc) {
-   mpi3mr_dprint(sc, MPI3MR_ERROR,
-   "Failed to allocate memory for controller CAM instance\n");
-   return (ENOMEM);
-   }
-
cam_sc->maxtargets = sc->facts.max_perids + 1;
 
TAILQ_INIT(&cam_sc->tgt_list);



git: 866dc4bd8139 - main - qat(4): Stop checking for failures from malloc(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=866dc4bd81398b478daefe4b7447b92422b4a06c

commit 866dc4bd81398b478daefe4b7447b92422b4a06c
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:32 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:32 +

qat(4): Stop checking for failures from malloc(M_WAITOK)

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45852
---
 sys/dev/qat/qat_common/adf_freebsd_dev_processes.c | 8 
 sys/dev/qat/qat_common/adf_freebsd_uio.c   | 8 
 sys/dev/qat/qat_common/adf_freebsd_uio_cleanup.c   | 3 ---
 sys/dev/qat/qat_hw/qat_4xxxvf/adf_drv.c| 5 -
 4 files changed, 24 deletions(-)

diff --git a/sys/dev/qat/qat_common/adf_freebsd_dev_processes.c 
b/sys/dev/qat/qat_common/adf_freebsd_dev_processes.c
index b8a17344bdea..a70f25d57dcb 100644
--- a/sys/dev/qat/qat_common/adf_freebsd_dev_processes.c
+++ b/sys/dev/qat/qat_common/adf_freebsd_dev_processes.c
@@ -146,8 +146,6 @@ adf_processes_open(struct cdev *dev, int oflags, int 
devtype, struct thread *td)
return ENXIO;
}
prv_data = malloc(sizeof(*prv_data), M_QAT, M_WAITOK | M_ZERO);
-   if (!prv_data)
-   return ENOMEM;
INIT_LIST_HEAD(&prv_data->list);
error = devfs_set_cdevpriv(prv_data, adf_processes_release);
if (error) {
@@ -573,14 +571,8 @@ adf_state_open(struct cdev *dev, int oflags, int devtype, 
struct thread *td)
int ret = 0;
 
prv_data = malloc(sizeof(*prv_data), M_QAT, M_WAITOK | M_ZERO);
-   if (!prv_data)
-   return -ENOMEM;
entry_proc_events =
malloc(sizeof(struct entry_proc_events), M_QAT, M_WAITOK | M_ZERO);
-   if (!entry_proc_events) {
-   free(prv_data, M_QAT);
-   return -ENOMEM;
-   }
mtx_lock(&mtx);
prv_data->cdev = dev;
prv_data->cdev->si_drv1 = prv_data;
diff --git a/sys/dev/qat/qat_common/adf_freebsd_uio.c 
b/sys/dev/qat/qat_common/adf_freebsd_uio.c
index c109fc79b0f4..64efde72b4b8 100644
--- a/sys/dev/qat/qat_common/adf_freebsd_uio.c
+++ b/sys/dev/qat/qat_common/adf_freebsd_uio.c
@@ -199,10 +199,6 @@ adf_alloc_bundle(struct adf_accel_dev *accel_dev, int 
bundle_nr)
 
accel = accel_dev->accel;
handle = malloc(sizeof(*handle), M_QAT, M_WAITOK | M_ZERO);
-   if (!handle) {
-   printf("ERROR in adf_alloc_bundle %d\n", __LINE__);
-   return ENOMEM;
-   }
handle->accel = accel;
handle->bundle = bundle_nr;
 
@@ -294,10 +290,6 @@ adf_uio_mmap_single(struct cdev *dev,
/* Adding pid to bundle list */
instance_rings =
malloc(sizeof(*instance_rings), M_QAT, M_WAITOK | M_ZERO);
-   if (!instance_rings) {
-   printf("QAT: Memory allocation error - line: %d\n", __LINE__);
-   return -ENOMEM;
-   }
instance_rings->user_pid = curproc->p_pid;
instance_rings->ring_mask = 0;
mutex_lock(&bundle->list_lock);
diff --git a/sys/dev/qat/qat_common/adf_freebsd_uio_cleanup.c 
b/sys/dev/qat/qat_common/adf_freebsd_uio_cleanup.c
index 6fb4cf0bf2f7..954e31c683ce 100644
--- a/sys/dev/qat/qat_common/adf_freebsd_uio_cleanup.c
+++ b/sys/dev/qat/qat_common/adf_freebsd_uio_cleanup.c
@@ -123,9 +123,6 @@ get_orphan_bundle(int bank,
 
orphan_bundle =
malloc(sizeof(*orphan_bundle), M_QAT, M_WAITOK | M_ZERO);
-   if (!orphan_bundle)
-   return ENOMEM;
-
csr_base = accel->bar->virt_addr;
orphan_bundle->csr_base = csr_base;
orphan_bundle->bank = bank;
diff --git a/sys/dev/qat/qat_hw/qat_4xxxvf/adf_drv.c 
b/sys/dev/qat/qat_hw/qat_4xxxvf/adf_drv.c
index 05a99ae43ab7..9b66ae4b2370 100644
--- a/sys/dev/qat/qat_hw/qat_4xxxvf/adf_drv.c
+++ b/sys/dev/qat/qat_hw/qat_4xxxvf/adf_drv.c
@@ -117,11 +117,6 @@ adf_attach(device_t dev)
}
/* Allocate and configure device configuration structure */
hw_data = malloc(sizeof(*hw_data), M_QAT_4XXXVF, M_WAITOK | M_ZERO);
-   if (!hw_data) {
-   ret = -ENOMEM;
-   goto out_err;
-   }
-
accel_dev->hw_device = hw_data;
adf_init_hw_data_4xxxiov(accel_dev->hw_device);
accel_pci_dev->revid = pci_get_revid(dev);



git: 4fb8a80a78aa - main - pms(4): Stop checking for failures from malloc(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=4fb8a80a78aa65e0b30bd5a74373512c678841c9

commit 4fb8a80a78aa65e0b30bd5a74373512c678841c9
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:32 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:32 +

pms(4): Stop checking for failures from malloc(M_WAITOK)

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45852
---
 sys/dev/pms/freebsd/driver/ini/src/agtiapi.c | 38 +++-
 1 file changed, 4 insertions(+), 34 deletions(-)

diff --git a/sys/dev/pms/freebsd/driver/ini/src/agtiapi.c 
b/sys/dev/pms/freebsd/driver/ini/src/agtiapi.c
index c8c9eb8c8dd8..cd1b80c3d712 100644
--- a/sys/dev/pms/freebsd/driver/ini/src/agtiapi.c
+++ b/sys/dev/pms/freebsd/driver/ini/src/agtiapi.c
@@ -318,13 +318,6 @@ int agtiapi_getdevlist( struct agtiapi_softc *pCard,
  sizeof(void *) );
   AGTIAPI_PRINTK("agtiapi_getdevlist: portCount %d\n", pCard->portCount);
   devList = malloc(memNeeded1, TEMP2, M_WAITOK); 
-  if (devList == NULL)
-  {
-AGTIAPI_PRINTK("agtiapi_getdevlist: failed to allocate memory\n");
-ret_val = IOCTL_CALL_FAIL;
-agIOCTLPayload->Status = IOCTL_ERR_STATUS_INTERNAL_ERROR;
-return ret_val;
-  }
   osti_memset(devList, 0,  memNeeded1);
   pPortalData = &pCard->pPortalData[0];
   pDeviceHandleList = (bit8*)devList;
@@ -970,13 +963,8 @@ static int agtiapi_attach( device_t devx )
   }
   else 
   {
-pmsc->pPortalData = (ag_portal_data_t *)
-malloc( sizeof(ag_portal_data_t) * pmsc->portCount,
+pmsc->pPortalData = malloc( sizeof(ag_portal_data_t) * pmsc->portCount,
 M_PMC_MPRT, M_ZERO | M_WAITOK );
-if (pmsc->pPortalData == NULL)
-{
-  AGTIAPI_PRINTK( "agtiapi_attach: Portal memory allocation ERROR\n" );
-}
   }
 
   pPortalData = pmsc->pPortalData;
@@ -1227,32 +1215,14 @@ STATIC agBOOLEAN agtiapi_InitCardHW( struct 
agtiapi_softc *pmsc )
   pmsc->flags |= AGTIAPI_SYS_INTR_ON;
 
   numVal = sizeof(ag_device_t) * pmsc->devDiscover;
-  pmsc->pDevList =
-(ag_device_t *)malloc( numVal, M_PMC_MDVT, M_ZERO | M_WAITOK );
-  if( !pmsc->pDevList ) {
-AGTIAPI_PRINTK( "agtiapi_InitCardHW: kmalloc %d DevList ERROR\n", numVal );
-panic( "agtiapi_InitCardHW\n" );
-return AGTIAPI_FAIL;
-  }
+  pmsc->pDevList = malloc( numVal, M_PMC_MDVT, M_ZERO | M_WAITOK );
 
 #ifdef LINUX_PERBI_SUPPORT
   numVal = sizeof(ag_slr_map_t) * pmsc->devDiscover;
-  pmsc->pSLRList =
-(ag_slr_map_t *)malloc( numVal, M_PMC_MSLR, M_ZERO | M_WAITOK );
-  if( !pmsc->pSLRList ) {
-AGTIAPI_PRINTK( "agtiapi_InitCardHW: kmalloc %d SLRList ERROR\n", numVal );
-panic( "agtiapi_InitCardHW SLRL\n" );
-return AGTIAPI_FAIL;
-  }
+  pmsc->pSLRList = malloc( numVal, M_PMC_MSLR, M_ZERO | M_WAITOK );
 
   numVal = sizeof(ag_tgt_map_t) * pmsc->devDiscover;
-  pmsc->pWWNList =
-(ag_tgt_map_t *)malloc( numVal, M_PMC_MTGT, M_ZERO | M_WAITOK );
-  if( !pmsc->pWWNList ) {
-AGTIAPI_PRINTK( "agtiapi_InitCardHW: kmalloc %d WWNList ERROR\n", numVal );
-panic( "agtiapi_InitCardHW WWNL\n" );
-return AGTIAPI_FAIL;
-  }
+  pmsc->pWWNList = malloc( numVal, M_PMC_MTGT, M_ZERO | M_WAITOK );
 
   // Get the WWN_to_target_ID mappings from the
   // holding area which contains the input of the



git: 761339c5544a - main - sume(4): Stop checking for failures from malloc(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=761339c5544a360df9d3bab70675fea246eb6a83

commit 761339c5544a360df9d3bab70675fea246eb6a83
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:33 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:33 +

sume(4): Stop checking for failures from malloc(M_WAITOK)

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45852
---
 sys/dev/sume/if_sume.c | 12 +---
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/sys/dev/sume/if_sume.c b/sys/dev/sume/if_sume.c
index 319853ac3c7a..7b2a27135e43 100644
--- a/sys/dev/sume/if_sume.c
+++ b/sys/dev/sume/if_sume.c
@@ -1195,16 +1195,11 @@ sume_probe_riffa_buffer(const struct sume_adapter 
*adapter,
 {
struct riffa_chnl_dir **rp;
bus_addr_t hw_addr;
-   int error, ch;
+   int ch;
device_t dev = adapter->dev;
 
-   error = ENOMEM;
*p = malloc(SUME_RIFFA_CHANNELS * sizeof(struct riffa_chnl_dir *),
M_SUME, M_ZERO | M_WAITOK);
-   if (*p == NULL) {
-   device_printf(dev, "malloc(%s) failed.\n", dir);
-   return (error);
-   }
 
rp = *p;
/* Allocate the chnl_dir structs themselves. */
@@ -1212,11 +1207,6 @@ sume_probe_riffa_buffer(const struct sume_adapter 
*adapter,
/* One direction. */
rp[ch] = malloc(sizeof(struct riffa_chnl_dir), M_SUME,
M_ZERO | M_WAITOK);
-   if (rp[ch] == NULL) {
-   device_printf(dev, "malloc(%s[%d]) riffa_chnl_dir "
-   "failed.\n", dir, ch);
-   return (error);
-   }
 
int err = bus_dma_tag_create(bus_get_dma_tag(dev),
4, 0,



git: 59121599bbda - main - sound: Stop checking for failures from malloc(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=59121599bbda1e4c3fc3c6e887cd48cd5e3afc70

commit 59121599bbda1e4c3fc3c6e887cd48cd5e3afc70
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:33 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:33 +

sound: Stop checking for failures from malloc(M_WAITOK)

Reviewed by:emaste
MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45852
---
 sys/dev/sound/macio/i2s.c  |  6 ++
 sys/dev/sound/usb/uaudio.c | 44 +++-
 2 files changed, 21 insertions(+), 29 deletions(-)

diff --git a/sys/dev/sound/macio/i2s.c b/sys/dev/sound/macio/i2s.c
index 5f8cb3aa15f7..647d66c27bba 100644
--- a/sys/dev/sound/macio/i2s.c
+++ b/sys/dev/sound/macio/i2s.c
@@ -241,10 +241,8 @@ i2s_attach(device_t self)
 * Register a hook for delayed attach in order to allow
 * the I2C controller to attach.
 */
-   if ((i2s_delayed_attach = malloc(sizeof(struct intr_config_hook), 
-   M_TEMP, M_WAITOK | M_ZERO)) == NULL)
-   return (ENOMEM);
-
+   i2s_delayed_attach = malloc(sizeof(struct intr_config_hook),
+   M_TEMP, M_WAITOK | M_ZERO);
i2s_delayed_attach->ich_func = i2s_postattach;
i2s_delayed_attach->ich_arg = sc;
 
diff --git a/sys/dev/sound/usb/uaudio.c b/sys/dev/sound/usb/uaudio.c
index 166af8a0857d..0a8878c072d2 100644
--- a/sys/dev/sound/usb/uaudio.c
+++ b/sys/dev/sound/usb/uaudio.c
@@ -2687,8 +2687,6 @@ uaudio_chan_init(struct uaudio_chan *ch, struct snd_dbuf 
*b,
DPRINTF("Worst case buffer is %d bytes\n", (int)buf_size);
 
ch->buf = malloc(buf_size, M_DEVBUF, M_WAITOK | M_ZERO);
-   if (ch->buf == NULL)
-   goto error;
if (sndbuf_setup(b, ch->buf, buf_size) != 0)
goto error;
 
@@ -3256,31 +3254,27 @@ uaudio_mixer_add_ctl_sub(struct uaudio_softc *sc, 
struct uaudio_mixer_node *mc)
malloc(sizeof(*p_mc_new), M_USBDEV, M_WAITOK);
int ch;
 
-   if (p_mc_new != NULL) {
-   memcpy(p_mc_new, mc, sizeof(*p_mc_new));
-   p_mc_new->next = sc->sc_mixer_root;
-   sc->sc_mixer_root = p_mc_new;
-   sc->sc_mixer_count++;
+   memcpy(p_mc_new, mc, sizeof(*p_mc_new));
+   p_mc_new->next = sc->sc_mixer_root;
+   sc->sc_mixer_root = p_mc_new;
+   sc->sc_mixer_count++;
 
-   /* set default value for all channels */
-   for (ch = 0; ch < p_mc_new->nchan; ch++) {
-   switch (p_mc_new->val_default) {
-   case 1:
-   /* 50% */
-   p_mc_new->wData[ch] = (p_mc_new->maxval + 
p_mc_new->minval) / 2;
-   break;
-   case 2:
-   /* 100% */
-   p_mc_new->wData[ch] = p_mc_new->maxval;
-   break;
-   default:
-   /* 0% */
-   p_mc_new->wData[ch] = p_mc_new->minval;
-   break;
-   }
+   /* set default value for all channels */
+   for (ch = 0; ch < p_mc_new->nchan; ch++) {
+   switch (p_mc_new->val_default) {
+   case 1:
+   /* 50% */
+   p_mc_new->wData[ch] = (p_mc_new->maxval + 
p_mc_new->minval) / 2;
+   break;
+   case 2:
+   /* 100% */
+   p_mc_new->wData[ch] = p_mc_new->maxval;
+   break;
+   default:
+   /* 0% */
+   p_mc_new->wData[ch] = p_mc_new->minval;
+   break;
}
-   } else {
-   DPRINTF("out of memory\n");
}
 }
 



git: f80483cdd58a - main - sdhci(4): Stop checking for failures from malloc(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=f80483cdd58a032ae2cfb2b9119824e9badc2c91

commit f80483cdd58a032ae2cfb2b9119824e9badc2c91
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:34 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:34 +

sdhci(4): Stop checking for failures from malloc(M_WAITOK)

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45852
---
 sys/dev/sdhci/sdhci_xenon_acpi.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/sys/dev/sdhci/sdhci_xenon_acpi.c b/sys/dev/sdhci/sdhci_xenon_acpi.c
index 01b6c14dc5f2..3e8b2c4a349c 100644
--- a/sys/dev/sdhci/sdhci_xenon_acpi.c
+++ b/sys/dev/sdhci/sdhci_xenon_acpi.c
@@ -86,8 +86,6 @@ sdhci_xenon_acpi_attach(device_t dev)
memset(&mmc_helper, 0, sizeof(mmc_helper));
 
slot = malloc(sizeof(*slot), M_DEVBUF, M_ZERO | M_WAITOK);
-   if (!slot)
-   return (ENOMEM);
 
/*
 * Don't use regularators.



git: 778ea7ed5a23 - main - vchiq(4): Stop checking for failures from malloc(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=778ea7ed5a23db9c4f9d8dc43a5cea26ded6231c

commit 778ea7ed5a23db9c4f9d8dc43a5cea26ded6231c
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:34 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:34 +

vchiq(4): Stop checking for failures from malloc(M_WAITOK)

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45852
---
 sys/contrib/vchiq/interface/vchiq_arm/vchiq_2835_arm.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/sys/contrib/vchiq/interface/vchiq_arm/vchiq_2835_arm.c 
b/sys/contrib/vchiq/interface/vchiq_arm/vchiq_2835_arm.c
index 279aacd0880a..ab8981e25cb2 100644
--- a/sys/contrib/vchiq/interface/vchiq_arm/vchiq_2835_arm.c
+++ b/sys/contrib/vchiq/interface/vchiq_arm/vchiq_2835_arm.c
@@ -278,8 +278,6 @@ vchiq_prepare_bulk_data(VCHIQ_BULK_T *bulk, 
VCHI_MEM_HANDLE_T memhandle,
 
WARN_ON(memhandle != VCHI_MEM_HANDLE_INVALID);
bi = malloc(sizeof(*bi), M_VCPAGELIST, M_WAITOK | M_ZERO);
-   if (bi == NULL)
-   return VCHIQ_ERROR;
 
ret = create_pagelist((char __user *)offset, size,
(dir == VCHIQ_BULK_RECEIVE)



git: 3f3f3ca25bc4 - main - ae(4): Stop checking for failures from taskqueue_create_fast(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=3f3f3ca25bc453315c6a1f5d16bfcc1189d41bdd

commit 3f3f3ca25bc453315c6a1f5d16bfcc1189d41bdd
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:34 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:34 +

ae(4): Stop checking for failures from taskqueue_create_fast(M_WAITOK)

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45853
---
 sys/dev/ae/if_ae.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/sys/dev/ae/if_ae.c b/sys/dev/ae/if_ae.c
index e424e1bd0e76..adbb3e48a4e3 100644
--- a/sys/dev/ae/if_ae.c
+++ b/sys/dev/ae/if_ae.c
@@ -362,12 +362,6 @@ ae_attach(device_t dev)
 */
sc->tq = taskqueue_create_fast("ae_taskq", M_WAITOK,
 taskqueue_thread_enqueue, &sc->tq);
-   if (sc->tq == NULL) {
-   device_printf(dev, "could not create taskqueue.\n");
-   ether_ifdetach(ifp);
-   error = ENXIO;
-   goto fail;
-   }
taskqueue_start_threads(&sc->tq, 1, PI_NET, "%s taskq",
device_get_nameunit(sc->dev));
 



git: 5cece2c24bfa - main - age(4): Stop checking for failures from taskqueue_create_fast(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=5cece2c24bfa618091e778df488fb2380fcecafe

commit 5cece2c24bfa618091e778df488fb2380fcecafe
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:35 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:35 +

age(4): Stop checking for failures from taskqueue_create_fast(M_WAITOK)

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45853
---
 sys/dev/age/if_age.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/sys/dev/age/if_age.c b/sys/dev/age/if_age.c
index 6630f2cf782d..10f99129401a 100644
--- a/sys/dev/age/if_age.c
+++ b/sys/dev/age/if_age.c
@@ -628,12 +628,6 @@ age_attach(device_t dev)
/* Create local taskq. */
sc->age_tq = taskqueue_create_fast("age_taskq", M_WAITOK,
taskqueue_thread_enqueue, &sc->age_tq);
-   if (sc->age_tq == NULL) {
-   device_printf(dev, "could not create taskqueue.\n");
-   ether_ifdetach(ifp);
-   error = ENXIO;
-   goto fail;
-   }
taskqueue_start_threads(&sc->age_tq, 1, PI_NET, "%s taskq",
device_get_nameunit(sc->age_dev));
 



git: 0cd3976d0762 - main - alc(4): Stop checking for failures from taskqueue_create_fast(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=0cd3976d076218ea10761dc3f38ecf8549768ad5

commit 0cd3976d076218ea10761dc3f38ecf8549768ad5
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:35 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:35 +

alc(4): Stop checking for failures from taskqueue_create_fast(M_WAITOK)

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45853
---
 sys/dev/alc/if_alc.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/sys/dev/alc/if_alc.c b/sys/dev/alc/if_alc.c
index 859d1214b46a..07ba02c33c88 100644
--- a/sys/dev/alc/if_alc.c
+++ b/sys/dev/alc/if_alc.c
@@ -1639,12 +1639,6 @@ alc_attach(device_t dev)
/* Create local taskq. */
sc->alc_tq = taskqueue_create_fast("alc_taskq", M_WAITOK,
taskqueue_thread_enqueue, &sc->alc_tq);
-   if (sc->alc_tq == NULL) {
-   device_printf(dev, "could not create taskqueue.\n");
-   ether_ifdetach(ifp);
-   error = ENXIO;
-   goto fail;
-   }
taskqueue_start_threads(&sc->alc_tq, 1, PI_NET, "%s taskq",
device_get_nameunit(sc->alc_dev));
 



git: f5524be39e26 - main - ale(4): Stop checking for failures from taskqueue_create_fast(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=f5524be39e26e3d7fb774ffe7711602c676a8b9e

commit f5524be39e26e3d7fb774ffe7711602c676a8b9e
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:35 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:35 +

ale(4): Stop checking for failures from taskqueue_create_fast(M_WAITOK)

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45853
---
 sys/dev/ale/if_ale.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/sys/dev/ale/if_ale.c b/sys/dev/ale/if_ale.c
index 5b3ae438810c..e4d61e636f8b 100644
--- a/sys/dev/ale/if_ale.c
+++ b/sys/dev/ale/if_ale.c
@@ -655,12 +655,6 @@ ale_attach(device_t dev)
/* Create local taskq. */
sc->ale_tq = taskqueue_create_fast("ale_taskq", M_WAITOK,
taskqueue_thread_enqueue, &sc->ale_tq);
-   if (sc->ale_tq == NULL) {
-   device_printf(dev, "could not create taskqueue.\n");
-   ether_ifdetach(ifp);
-   error = ENXIO;
-   goto fail;
-   }
taskqueue_start_threads(&sc->ale_tq, 1, PI_NET, "%s taskq",
device_get_nameunit(sc->ale_dev));
 



git: b29adaaf44f6 - main - axgbe: Stop checking for failures from taskqueue_create(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=b29adaaf44f6cf9433c782bbeeefd12d74d395a5

commit b29adaaf44f6cf9433c782bbeeefd12d74d395a5
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:36 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:36 +

axgbe: Stop checking for failures from taskqueue_create(M_WAITOK)

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45853
---
 sys/dev/axgbe/if_axgbe_pci.c | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/sys/dev/axgbe/if_axgbe_pci.c b/sys/dev/axgbe/if_axgbe_pci.c
index 320799e77188..d3078a1c33c1 100644
--- a/sys/dev/axgbe/if_axgbe_pci.c
+++ b/sys/dev/axgbe/if_axgbe_pci.c
@@ -561,11 +561,6 @@ axgbe_if_attach_pre(if_ctx_t ctx)
/* create the workqueue */
pdata->dev_workqueue = taskqueue_create("axgbe", M_WAITOK,
taskqueue_thread_enqueue, &pdata->dev_workqueue);
-   if (pdata->dev_workqueue == NULL) {
-   axgbe_error("Unable to allocate workqueue\n");
-   ret = ENOMEM;
-   goto free_channels;
-   }
ret = taskqueue_start_threads(&pdata->dev_workqueue, 1, PI_NET,
"axgbe dev taskq");
if (ret) {
@@ -581,8 +576,6 @@ axgbe_if_attach_pre(if_ctx_t ctx)
 
 free_task_queue:
taskqueue_free(pdata->dev_workqueue);
-
-free_channels:
axgbe_free_channels(sc);
 
 release_bus_resource:



git: d44bc2f07b97 - main - bge(4): Stop checking for failures from taskqueue_create_fast(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=d44bc2f07b971fe1f451a1fff0389650a2502422

commit d44bc2f07b971fe1f451a1fff0389650a2502422
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:36 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:36 +

bge(4): Stop checking for failures from taskqueue_create_fast(M_WAITOK)

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45853
---
 sys/dev/bge/if_bge.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/sys/dev/bge/if_bge.c b/sys/dev/bge/if_bge.c
index 23259179cc62..6c3301b1473a 100644
--- a/sys/dev/bge/if_bge.c
+++ b/sys/dev/bge/if_bge.c
@@ -3890,12 +3890,6 @@ again:
~BGE_MSIMODE_ONE_SHOT_DISABLE);
sc->bge_tq = taskqueue_create_fast("bge_taskq", M_WAITOK,
taskqueue_thread_enqueue, &sc->bge_tq);
-   if (sc->bge_tq == NULL) {
-   device_printf(dev, "could not create taskqueue.\n");
-   ether_ifdetach(ifp);
-   error = ENOMEM;
-   goto fail;
-   }
error = taskqueue_start_threads(&sc->bge_tq, 1, PI_NET,
"%s taskq", device_get_nameunit(sc->bge_dev));
if (error != 0) {



git: af28fc3c191c - main - cas(4): Stop checking for failures from taskqueue_create_fast(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=af28fc3c191cf572f7def767c60fff59d48947df

commit af28fc3c191cf572f7def767c60fff59d48947df
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:37 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:37 +

cas(4): Stop checking for failures from taskqueue_create_fast(M_WAITOK)

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45853
---
 sys/dev/cas/if_cas.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/sys/dev/cas/if_cas.c b/sys/dev/cas/if_cas.c
index 76d1b713e5bb..1f684097bd3a 100644
--- a/sys/dev/cas/if_cas.c
+++ b/sys/dev/cas/if_cas.c
@@ -205,11 +205,6 @@ cas_attach(struct cas_softc *sc)
TASK_INIT(&sc->sc_tx_task, 1, cas_tx_task, ifp);
sc->sc_tq = taskqueue_create_fast("cas_taskq", M_WAITOK,
taskqueue_thread_enqueue, &sc->sc_tq);
-   if (sc->sc_tq == NULL) {
-   device_printf(sc->sc_dev, "could not create taskqueue\n");
-   error = ENXIO;
-   goto fail_ifnet;
-   }
error = taskqueue_start_threads(&sc->sc_tq, 1, PI_NET, "%s taskq",
device_get_nameunit(sc->sc_dev));
if (error != 0) {
@@ -462,7 +457,6 @@ cas_attach(struct cas_softc *sc)
bus_dma_tag_destroy(sc->sc_pdmatag);
  fail_taskq:
taskqueue_free(sc->sc_tq);
- fail_ifnet:
if_free(ifp);
return (error);
 }



git: 36ef39831fe0 - main - dpaa2: Stop checking for failures from malloc/taskqueue_create(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=36ef39831fe0e89f0b1672340a44c4ac1183158e

commit 36ef39831fe0e89f0b1672340a44c4ac1183158e
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:37 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:37 +

dpaa2: Stop checking for failures from malloc/taskqueue_create(M_WAITOK)

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45853
---
 sys/dev/dpaa2/dpaa2_channel.c |  7 ---
 sys/dev/dpaa2/dpaa2_mc.c  |  2 --
 sys/dev/dpaa2/dpaa2_ni.c  | 15 ---
 3 files changed, 24 deletions(-)

diff --git a/sys/dev/dpaa2/dpaa2_channel.c b/sys/dev/dpaa2/dpaa2_channel.c
index 87b76923a16d..654c6f2baf70 100644
--- a/sys/dev/dpaa2/dpaa2_channel.c
+++ b/sys/dev/dpaa2/dpaa2_channel.c
@@ -146,12 +146,6 @@ dpaa2_chan_setup(device_t dev, device_t iodev, device_t 
condev, device_t bpdev,
}
 
ch = malloc(sizeof(struct dpaa2_channel), M_DPAA2_CH, M_WAITOK | 
M_ZERO);
-   if (ch == NULL) {
-   device_printf(dev, "%s: malloc() failed\n", __func__);
-   error = ENOMEM;
-   goto fail_malloc;
-   }
-
ch->ni_dev = dev;
ch->io_dev = iodev;
ch->con_dev = condev;
@@ -281,7 +275,6 @@ fail_dma_setup:
/*  taskqueue_drain(ch->cleanup_tq, &ch->cleanup_task); */
/* } */
/* taskqueue_free(ch->cleanup_tq); */
-fail_malloc:
(void)DPAA2_CMD_CON_DISABLE(dev, child, DPAA2_CMD_TK(&cmd, contk));
 fail_con_enable:
(void)DPAA2_CMD_CON_CLOSE(dev, child, DPAA2_CMD_TK(&cmd, contk));
diff --git a/sys/dev/dpaa2/dpaa2_mc.c b/sys/dev/dpaa2/dpaa2_mc.c
index 66867a18068c..da8f8a077d6b 100644
--- a/sys/dev/dpaa2/dpaa2_mc.c
+++ b/sys/dev/dpaa2/dpaa2_mc.c
@@ -462,8 +462,6 @@ dpaa2_mc_manage_dev(device_t mcdev, device_t dpaa2_dev, 
uint32_t flags)
return (EINVAL);
 
di = malloc(sizeof(*di), M_DPAA2_MC, M_WAITOK | M_ZERO);
-   if (!di)
-   return (ENOMEM);
di->dpaa2_dev = dpaa2_dev;
di->flags = flags;
di->owners = 0;
diff --git a/sys/dev/dpaa2/dpaa2_ni.c b/sys/dev/dpaa2/dpaa2_ni.c
index a21351a20b49..6ed656849709 100644
--- a/sys/dev/dpaa2/dpaa2_ni.c
+++ b/sys/dev/dpaa2/dpaa2_ni.c
@@ -588,11 +588,6 @@ dpaa2_ni_attach(device_t dev)
/* Create a taskqueue thread to release new buffers to the pool. */
sc->bp_taskq = taskqueue_create(tq_name, M_WAITOK,
taskqueue_thread_enqueue, &sc->bp_taskq);
-   if (sc->bp_taskq == NULL) {
-   device_printf(dev, "%s: failed to allocate task queue: %s\n",
-   __func__, tq_name);
-   goto close_ni;
-   }
taskqueue_start_threads(&sc->bp_taskq, 1, PI_NET, "%s", tq_name);
 
/* sc->cleanup_taskq = taskqueue_create("dpaa2_ch cleanup", M_WAITOK, */
@@ -1339,21 +1334,11 @@ dpaa2_ni_setup_tx_flow(device_t dev, struct dpaa2_ni_fq 
*fq)
for (uint64_t j = 0; j < DPAA2_NI_BUFS_PER_TX; j++) {
buf = malloc(sizeof(struct dpaa2_buf), M_DPAA2_TXB,
M_WAITOK);
-   if (buf == NULL) {
-   device_printf(dev, "%s: malloc() failed 
(buf)\n",
-   __func__);
-   return (ENOMEM);
-   }
/* Keep DMA tag and Tx ring linked to the buffer */
DPAA2_BUF_INIT_TAGOPT(buf, ch->tx_dmat, tx);
 
buf->sgt = malloc(sizeof(struct dpaa2_buf), M_DPAA2_TXB,
M_WAITOK);
-   if (buf->sgt == NULL) {
-   device_printf(dev, "%s: malloc() failed 
(sgt)\n",
-   __func__);
-   return (ENOMEM);
-   }
/* Link SGT to DMA tag and back to its Tx buffer */
DPAA2_BUF_INIT_TAGOPT(buf->sgt, ch->sgt_dmat, buf);
 



git: 3fdef8e85502 - main - jme(4): Stop checking for failures from taskqueue_create_fast(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=3fdef8e855027d5c9bec06e2a53e8f99f7d5694b

commit 3fdef8e855027d5c9bec06e2a53e8f99f7d5694b
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:38 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:38 +

jme(4): Stop checking for failures from taskqueue_create_fast(M_WAITOK)

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45853
---
 sys/dev/jme/if_jme.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/sys/dev/jme/if_jme.c b/sys/dev/jme/if_jme.c
index 96824e2d7f27..4f739ec26347 100644
--- a/sys/dev/jme/if_jme.c
+++ b/sys/dev/jme/if_jme.c
@@ -872,12 +872,6 @@ jme_attach(device_t dev)
/* Create local taskq. */
sc->jme_tq = taskqueue_create_fast("jme_taskq", M_WAITOK,
taskqueue_thread_enqueue, &sc->jme_tq);
-   if (sc->jme_tq == NULL) {
-   device_printf(dev, "could not create taskqueue.\n");
-   ether_ifdetach(ifp);
-   error = ENXIO;
-   goto fail;
-   }
taskqueue_start_threads(&sc->jme_tq, 1, PI_NET, "%s taskq",
device_get_nameunit(sc->jme_dev));
 



git: 57cd8f27b727 - main - liquidio(4): Stop checking for failures from malloc/taskqueue_create/buf_ring_alloc(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=57cd8f27b727e7a87312f6f141cfa13807dc81a0

commit 57cd8f27b727e7a87312f6f141cfa13807dc81a0
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:38 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:38 +

liquidio(4): Stop checking for failures from 
malloc/taskqueue_create/buf_ring_alloc(M_WAITOK)

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45853
---
 sys/dev/liquidio/base/lio_request_manager.c  | 9 -
 sys/dev/liquidio/base/lio_response_manager.c | 4 
 sys/dev/liquidio/lio_main.c  | 4 
 sys/dev/liquidio/lio_sysctl.c| 3 ---
 4 files changed, 20 deletions(-)

diff --git a/sys/dev/liquidio/base/lio_request_manager.c 
b/sys/dev/liquidio/base/lio_request_manager.c
index f4eae0c8bf31..95eac12ecf3b 100644
--- a/sys/dev/liquidio/base/lio_request_manager.c
+++ b/sys/dev/liquidio/base/lio_request_manager.c
@@ -159,11 +159,6 @@ lio_init_instr_queue(struct octeon_device *oct, union 
octeon_txpciq txpciq,
db_tq = &oct->check_db_tq[iq_no];
db_tq->tq = taskqueue_create("lio_check_db_timeout", M_WAITOK,
 taskqueue_thread_enqueue, &db_tq->tq);
-   if (db_tq->tq == NULL) {
-   lio_dev_err(oct, "check db wq create failed for iq %d\n",
-   iq_no);
-   return (1);
-   }
 
TIMEOUT_TASK_INIT(db_tq->tq, &db_tq->work, 0, lio_check_db_timeout,
  (void *)db_tq);
@@ -179,10 +174,6 @@ lio_init_instr_queue(struct octeon_device *oct, union 
octeon_txpciq txpciq,
oct->instr_queue[iq_no]->br =
buf_ring_alloc(LIO_BR_SIZE, M_DEVBUF, M_WAITOK,
   &oct->instr_queue[iq_no]->enq_lock);
-   if (oct->instr_queue[iq_no]->br == NULL) {
-   lio_dev_err(oct, "Critical Failure setting up buf ring\n");
-   return (1);
-   }
 
return (0);
 }
diff --git a/sys/dev/liquidio/base/lio_response_manager.c 
b/sys/dev/liquidio/base/lio_response_manager.c
index 12a3ad60521e..ac5fc6229885 100644
--- a/sys/dev/liquidio/base/lio_response_manager.c
+++ b/sys/dev/liquidio/base/lio_response_manager.c
@@ -59,10 +59,6 @@ lio_setup_response_list(struct octeon_device *oct)
ctq = &oct->dma_comp_tq;
ctq->tq = taskqueue_create("lio_dma_comp", M_WAITOK,
   taskqueue_thread_enqueue, &ctq->tq);
-   if (ctq->tq == NULL) {
-   lio_dev_err(oct, "failed to create wq thread\n");
-   return (-ENOMEM);
-   }
 
TIMEOUT_TASK_INIT(ctq->tq, &ctq->work, 0, lio_poll_req_completion,
  (void *)ctq);
diff --git a/sys/dev/liquidio/lio_main.c b/sys/dev/liquidio/lio_main.c
index 7104ff07674f..3c73a6b10eed 100644
--- a/sys/dev/liquidio/lio_main.c
+++ b/sys/dev/liquidio/lio_main.c
@@ -1854,10 +1854,6 @@ lio_setup_rx_oom_poll_fn(if_t ifp)
rx_status_tq->tq = taskqueue_create("lio_rx_oom_status", M_WAITOK,
taskqueue_thread_enqueue,
&rx_status_tq->tq);
-   if (rx_status_tq->tq == NULL) {
-   lio_dev_err(oct, "unable to create lio rx oom status tq\n");
-   return (-1);
-   }
 
TIMEOUT_TASK_INIT(rx_status_tq->tq, &rx_status_tq->work, 0,
  lio_poll_check_rx_oom_status, (void *)rx_status_tq);
diff --git a/sys/dev/liquidio/lio_sysctl.c b/sys/dev/liquidio/lio_sysctl.c
index 729f4d432274..61a7e96098c8 100644
--- a/sys/dev/liquidio/lio_sysctl.c
+++ b/sys/dev/liquidio/lio_sysctl.c
@@ -744,9 +744,6 @@ lio_get_regs(SYSCTL_HANDLER_ARGS)
regbuf = malloc(sizeof(char) * LIO_REGDUMP_LEN_, M_DEVBUF,
M_WAITOK | M_ZERO);
 
-   if (regbuf == NULL)
-   return (error);
-
switch (oct->chip_id) {
case LIO_CN23XX_PF_VID:
len += lio_cn23xx_pf_read_csr_reg(regbuf, oct);



git: 7ea3fd3bb5f4 - main - mxge(4): Stop checking for failures from taskqueue_create(M_WAITOK)

2024-09-03 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=7ea3fd3bb5f4039c372fd72aeef004fe12454537

commit 7ea3fd3bb5f4039c372fd72aeef004fe12454537
Author: Zhenlei Huang 
AuthorDate: 2024-09-03 10:25:38 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-03 10:25:38 +

mxge(4): Stop checking for failures from taskqueue_create(M_WAITOK)

MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45853
---
 sys/dev/mxge/if_mxge.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/sys/dev/mxge/if_mxge.c b/sys/dev/mxge/if_mxge.c
index 47793232d8d5..f36f41d53b40 100644
--- a/sys/dev/mxge/if_mxge.c
+++ b/sys/dev/mxge/if_mxge.c
@@ -4615,10 +4615,6 @@ mxge_attach(device_t dev)
TASK_INIT(&sc->watchdog_task, 1, mxge_watchdog_task, sc);
sc->tq = taskqueue_create("mxge_taskq", M_WAITOK,
  taskqueue_thread_enqueue, &sc->tq);
-   if (sc->tq == NULL) {
-   err = ENOMEM;
-   goto abort_with_nothing;
-   }
 
err = bus_dma_tag_create(bus_get_dma_tag(dev),  /* parent */
 1, /* alignment */
@@ -4815,7 +4811,6 @@ abort_with_tq:
taskqueue_free(sc->tq);
sc->tq = NULL;
}
-abort_with_nothing:
return err;
 }
 



git: 343bf78e4871 - main - bpf: Update a comment

2024-09-10 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=343bf78e487190557889c8ba53d8080b268867f7

commit 343bf78e487190557889c8ba53d8080b268867f7
Author: Zhenlei Huang 
AuthorDate: 2024-09-10 10:03:32 +
Commit: Zhenlei Huang 
CommitDate: 2024-09-10 10:03:32 +

bpf: Update a comment

This comment was introduced by fix [1], later the fix was refined by
change [2], and the context of the usage of `m_get2()` and `m_getjcl()`
got lost, then the comment became obscure.

Update to reflect the current behavior.

1. f13da24715a7 net/bpf: Fix writing of buffer bigger than PAGESIZE
2. a051ca72e281 Introduce m_get3()

Fixes:  a051ca72e281 Introduce m_get3()
MFC after:  3 days
---
 sys/net/bpf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/net/bpf.c b/sys/net/bpf.c
index 7983337064be..5dfa6fb30565 100644
--- a/sys/net/bpf.c
+++ b/sys/net/bpf.c
@@ -647,7 +647,7 @@ bpf_movein(struct uio *uio, int linktype, struct ifnet 
*ifp, struct mbuf **mp,
if (len < hlen || len - hlen > ifp->if_mtu)
return (EMSGSIZE);
 
-   /* Allocate a mbuf for our write, since m_get2 fails if len >= to 
MJUMPAGESIZE, use m_getjcl for bigger buffers */
+   /* Allocate a mbuf, up to MJUM16BYTES bytes, for our write. */
m = m_get3(len, M_WAITOK, MT_DATA, M_PKTHDR);
if (m == NULL)
return (EIO);



git: e7102929bf4f - main - ethernet: Fix logging of frame length

2024-04-08 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=e7102929bf4fea4bf22855d2d6031edf6c413608

commit e7102929bf4fea4bf22855d2d6031edf6c413608
Author: Zhenlei Huang 
AuthorDate: 2024-04-08 16:44:33 +
Commit: Zhenlei Huang 
CommitDate: 2024-04-08 16:44:33 +

ethernet: Fix logging of frame length

Both the mbuf length and the total packet length are signed.

While here, update a stall comment to reflect the current practice.

Reviewed by:kp
MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D42390
---
 sys/net/if_ethersubr.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c
index 4332f4ce864e..eeb2c1ea4ef3 100644
--- a/sys/net/if_ethersubr.c
+++ b/sys/net/if_ethersubr.c
@@ -534,10 +534,10 @@ ether_input_internal(struct ifnet *ifp, struct mbuf *m)
return;
}
 #endif
-   if (m->m_len < ETHER_HDR_LEN) {
-   /* XXX maybe should pullup? */
+   if (__predict_false(m->m_len < ETHER_HDR_LEN)) {
+   /* Drivers should pullup and ensure the mbuf is valid */
if_printf(ifp, "discard frame w/o leading ethernet "
-   "header (len %u pkt len %u)\n",
+   "header (len %d pkt len %d)\n",
m->m_len, m->m_pkthdr.len);
if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
m_freem(m);



git: 6fe4d8395bc5 - main - debugnet: Fix logging of frame length

2024-04-08 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=6fe4d8395bc5ec51a5ec68b5f1176b4710676b7c

commit 6fe4d8395bc5ec51a5ec68b5f1176b4710676b7c
Author: Zhenlei Huang 
AuthorDate: 2024-04-08 16:47:06 +
Commit: Zhenlei Huang 
CommitDate: 2024-04-08 16:47:10 +

debugnet: Fix logging of frame length

MFC after:  1 week
---
 sys/net/debugnet.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/net/debugnet.c b/sys/net/debugnet.c
index c54c1a3904ec..c6f57ec84618 100644
--- a/sys/net/debugnet.c
+++ b/sys/net/debugnet.c
@@ -566,7 +566,7 @@ debugnet_input_one(struct ifnet *ifp, struct mbuf *m)
}
if (m->m_len < ETHER_HDR_LEN) {
DNETDEBUG_IF(ifp,
-   "discard frame without leading eth header (len %u pktlen %u)\n",
+   "discard frame without leading eth header (len %d pktlen %d)\n",
m->m_len, m->m_pkthdr.len);
goto done;
}



git: f6f67f58c19d - main - ng_socket: Treat EEXIST from kern_kldload() as success

2024-04-09 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=f6f67f58c19db4f25f5c2cf4869efc7054493a55

commit f6f67f58c19db4f25f5c2cf4869efc7054493a55
Author: Zhenlei Huang 
AuthorDate: 2024-04-09 10:04:47 +
Commit: Zhenlei Huang 
CommitDate: 2024-04-09 10:04:47 +

ng_socket: Treat EEXIST from kern_kldload() as success

EEXIST is possible in a race condition.

Inspired by:ffc72591b1f5 (Don't worry if a module is already loaded ...)
Reviewed by:glebius
MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D44633
---
 sys/netgraph/ng_socket.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/sys/netgraph/ng_socket.c b/sys/netgraph/ng_socket.c
index c356f7d6aa12..c570584d4b44 100644
--- a/sys/netgraph/ng_socket.c
+++ b/sys/netgraph/ng_socket.c
@@ -285,11 +285,15 @@ ngc_send(struct socket *so, int flags, struct mbuf *m, 
struct sockaddr *addr,
if (ng_findtype(mkp->type) == NULL) {
char filename[NG_TYPESIZ + 3];
int fileid;
+   bool loaded;
 
/* Not found, try to load it as a loadable module. */
snprintf(filename, sizeof(filename), "ng_%s",
mkp->type);
error = kern_kldload(curthread, filename, &fileid);
+   loaded = (error == 0);
+   if (error == EEXIST)
+   error = 0;
if (error != 0) {
free(msg, M_NETGRAPH_MSG);
goto release;
@@ -298,9 +302,10 @@ ngc_send(struct socket *so, int flags, struct mbuf *m, 
struct sockaddr *addr,
/* See if type has been loaded successfully. */
if (ng_findtype(mkp->type) == NULL) {
free(msg, M_NETGRAPH_MSG);
-   (void)kern_kldunload(curthread, fileid,
-   LINKER_UNLOAD_NORMAL);
-   error =  ENXIO;
+   if (loaded)
+   (void)kern_kldunload(curthread, fileid,
+   LINKER_UNLOAD_NORMAL);
+   error = ENXIO;
goto release;
}
}



git: 73585176ffd8 - main - if_bridge: Minor style fixes

2024-04-25 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=73585176ffd84c13d68cad67c2ca81643f09075c

commit 73585176ffd84c13d68cad67c2ca81643f09075c
Author: Zhenlei Huang 
AuthorDate: 2024-04-25 18:19:11 +
Commit: Zhenlei Huang 
CommitDate: 2024-04-25 18:19:11 +

if_bridge: Minor style fixes

And more comments on the #ifdef INET blocks to improve readability.

While here, revert the order of two prototypes to produce minimal diff
compared to stable branches.

MFC with:   65767e6126a7
---
 sys/net/if_bridge.c | 16 ++--
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c
index 7b44d85d1fe8..1e6f9b578ee3 100644
--- a/sys/net/if_bridge.c
+++ b/sys/net/if_bridge.c
@@ -403,19 +403,16 @@ static intbridge_ioctl_sproto(struct bridge_softc 
*, void *);
 static int bridge_ioctl_stxhc(struct bridge_softc *, void *);
 static int bridge_pfil(struct mbuf **, struct ifnet *, struct ifnet *,
int);
-static voidbridge_linkstate(struct ifnet *ifp);
-static voidbridge_linkcheck(struct bridge_softc *sc);
-
 #ifdef INET
 static int bridge_ip_checkbasic(struct mbuf **mp);
 static int bridge_fragment(struct ifnet *, struct mbuf **mp,
struct ether_header *, int, struct llc *);
 #endif /* INET */
-
 #ifdef INET6
 static int bridge_ip6_checkbasic(struct mbuf **mp);
 #endif /* INET6 */
-
+static voidbridge_linkstate(struct ifnet *ifp);
+static voidbridge_linkcheck(struct bridge_softc *sc);
 
 /*
  * Use the "null" value from IEEE 802.1Q-2014 Table 9-2
@@ -3459,7 +3456,7 @@ bridge_pfil(struct mbuf **mp, struct ifnet *bifp, struct 
ifnet *ifp, int dir)
if (V_pfil_ipfw_arp == 0)
return (0); /* Automatically pass */
 
-   /*FALLTHROUGH*/
+   /* FALLTHROUGH */
case ETHERTYPE_IP:
 #endif
 #ifdef INET6
@@ -3587,8 +3584,7 @@ bridge_pfil(struct mbuf **mp, struct ifnet *bifp, struct 
ifnet *ifp, int dir)
ip->ip_sum = in_cksum(*mp, hlen);
 
break;
-#endif
-
+#endif /* INET */
 #ifdef INET6
case ETHERTYPE_IPV6:
if (V_pfil_bridge && dir == PFIL_OUT && bifp != NULL && (rv =
@@ -3747,7 +3743,7 @@ bad:
*mp = m;
return (-1);
 }
-#endif
+#endif /* INET */
 
 #ifdef INET6
 /*
@@ -3880,7 +3876,7 @@ dropit:
}
return (error);
 }
-#endif
+#endif /* INET */
 
 static void
 bridge_linkstate(struct ifnet *ifp)



git: d9f1f0a90183 - main - boottrace: Use NULL for SYSINIT's last arg, which is a pointer type

2024-05-13 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=d9f1f0a901831ff960380fe82a2abe99a3721f87

commit d9f1f0a901831ff960380fe82a2abe99a3721f87
Author: Zhenlei Huang 
AuthorDate: 2024-05-14 04:03:50 +
Commit: Zhenlei Huang 
CommitDate: 2024-05-14 04:03:50 +

boottrace: Use NULL for SYSINIT's last arg, which is a pointer type

MFC after:  3 days
---
 sys/kern/kern_boottrace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/kern/kern_boottrace.c b/sys/kern/kern_boottrace.c
index 86fee4f47fbe..1b097e7378ad 100644
--- a/sys/kern/kern_boottrace.c
+++ b/sys/kern/kern_boottrace.c
@@ -613,4 +613,4 @@ boottrace_init(void)
st.table = malloc(st.size * sizeof(struct bt_event), M_BOOTTRACE,
M_WAITOK | M_ZERO);
 }
-SYSINIT(boottrace, SI_SUB_CPU, SI_ORDER_ANY, boottrace_init, 0);
+SYSINIT(boottrace, SI_SUB_CPU, SI_ORDER_ANY, boottrace_init, NULL);



Re: git: f7d45c5443ed - main - bhyve: avoid side effect in assertion

2024-05-17 Thread Zhenlei Huang



> On May 18, 2024, at 4:00 AM, Ed Maste  wrote:
> 
> The branch main has been updated by emaste:
> 
> URL: 
> https://cgit.FreeBSD.org/src/commit/?id=f7d45c5443edc99857fdda19c68301b5ec4a8971
> 
> commit f7d45c5443edc99857fdda19c68301b5ec4a8971
> Author: Pierre Pronchery 
> AuthorDate: 2024-05-17 07:31:32 +
> Commit: Ed Maste 
> CommitDate: 2024-05-17 19:45:18 +
> 
>bhyve: avoid side effect in assertion
> 
>An assert() was setting the error variable instead of checking it.
> 
>Reported by:Coverity Scan
>CID:1521431
>Reviewed by:jhb
>Sponsored by:   The FreeBSD Foundation
>Pull Request:   https://github.com/freebsd/freebsd-src/pull/1244
> ---
> usr.sbin/bhyve/tpm_ppi_qemu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/usr.sbin/bhyve/tpm_ppi_qemu.c b/usr.sbin/bhyve/tpm_ppi_qemu.c
> index ad66ecb09683..239d39184589 100644
> --- a/usr.sbin/bhyve/tpm_ppi_qemu.c
> +++ b/usr.sbin/bhyve/tpm_ppi_qemu.c
> @@ -161,7 +161,7 @@ tpm_ppi_deinit(void *sc)
>   ppi = sc;
> 
>   error = unregister_mem(&ppi_mmio);
> - assert(error = 0);
> + assert(error == 0);

Emm, does that not get caught by compilers ?

> 
>   free(ppi);
> }






Re: git: f7d45c5443ed - main - bhyve: avoid side effect in assertion

2024-05-17 Thread Zhenlei Huang



> On May 18, 2024, at 8:57 AM, Zhenlei Huang  wrote:
> 
> 
> 
>> On May 18, 2024, at 4:00 AM, Ed Maste  wrote:
>> 
>> The branch main has been updated by emaste:
>> 
>> URL: 
>> https://cgit.FreeBSD.org/src/commit/?id=f7d45c5443edc99857fdda19c68301b5ec4a8971
>> 
>> commit f7d45c5443edc99857fdda19c68301b5ec4a8971
>> Author: Pierre Pronchery 
>> AuthorDate: 2024-05-17 07:31:32 +
>> Commit: Ed Maste 
>> CommitDate: 2024-05-17 19:45:18 +
>> 
>>   bhyve: avoid side effect in assertion
>> 
>>   An assert() was setting the error variable instead of checking it.
>> 
>>   Reported by:Coverity Scan
>>   CID:1521431
>>   Reviewed by:jhb
>>   Sponsored by:   The FreeBSD Foundation
>>   Pull Request:   https://github.com/freebsd/freebsd-src/pull/1244
>> ---
>> usr.sbin/bhyve/tpm_ppi_qemu.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/usr.sbin/bhyve/tpm_ppi_qemu.c b/usr.sbin/bhyve/tpm_ppi_qemu.c
>> index ad66ecb09683..239d39184589 100644
>> --- a/usr.sbin/bhyve/tpm_ppi_qemu.c
>> +++ b/usr.sbin/bhyve/tpm_ppi_qemu.c
>> @@ -161,7 +161,7 @@ tpm_ppi_deinit(void *sc)
>>  ppi = sc;
>> 
>>  error = unregister_mem(&ppi_mmio);
>> -assert(error = 0);
>> +assert(error == 0);
> 
> Emm, does that not get caught by compilers ?

Unfortunately not. assert is defined as a macro as such

```
#define assert(e)   ((e) ? (void)0 : __assert(__func__, __FILE__, \
__LINE__, #e))
```

So `e` is enclosed with () and compiler can not catch that.

> 
>> 
>>  free(ppi);
>> }
> 
> 
> 






git: 92f2a4c820fe - main - compat_freebsd4: Add const qualifier to the local variable s inside function freebsd4_uname()

2024-05-19 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=92f2a4c820fea9efcb6ee6a7029495c8152958c1

commit 92f2a4c820fea9efcb6ee6a7029495c8152958c1
Author: Zhenlei Huang 
AuthorDate: 2024-05-20 04:02:32 +
Commit: Zhenlei Huang 
CommitDate: 2024-05-20 04:02:32 +

compat_freebsd4: Add const qualifier to the local variable s inside 
function freebsd4_uname()

This local variable s is for iterating characters of global variable
`version`. The content of `version` is not going to be altered by
function freebsd4_uname().

MFC after:  1 week
---
 sys/kern/kern_xxx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sys/kern/kern_xxx.c b/sys/kern/kern_xxx.c
index 46155cf6a73e..fb76d420df7c 100644
--- a/sys/kern/kern_xxx.c
+++ b/sys/kern/kern_xxx.c
@@ -315,7 +315,8 @@ freebsd4_uname(struct thread *td, struct 
freebsd4_uname_args *uap)
 {
int name[2], error;
size_t len;
-   char *s, *us;
+   const char *s;
+   char *us;
 
name[0] = CTL_KERN;
name[1] = KERN_OSTYPE;



git: 68c890b4433d - main - linux(4): Add const qualifier to the value parameter of function handle_string()

2024-05-19 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=68c890b4433d3655c7df91cc43f89f4d6a8b35e4

commit 68c890b4433d3655c7df91cc43f89f4d6a8b35e4
Author: Zhenlei Huang 
AuthorDate: 2024-05-20 04:02:33 +
Commit: Zhenlei Huang 
CommitDate: 2024-05-20 04:02:33 +

linux(4): Add const qualifier to the value parameter of function 
handle_string()

The content that `value` point to is not going to be altered by function
handle_string().

MFC after:  1 week
---
 sys/compat/linux/linux_sysctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/compat/linux/linux_sysctl.c b/sys/compat/linux/linux_sysctl.c
index 65c64a7ba563..97341c051af7 100644
--- a/sys/compat/linux/linux_sysctl.c
+++ b/sys/compat/linux/linux_sysctl.c
@@ -74,7 +74,7 @@ LIN_SDT_PROBE_DEFINE1(sysctl, linux_sysctl, 
unsupported_sysctl, "char *");
 
 #ifdef LINUX_LEGACY_SYSCALLS
 static int
-handle_string(struct l___sysctl_args *la, char *value)
+handle_string(struct l___sysctl_args *la, const char *value)
 {
int error;
 



git: 93fbfef0b503 - main - if_vxlan(4): Add checking for loops and nesting of tunnels

2024-05-20 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=93fbfef0b50354b7a1620822454ef29cd415cb2d

commit 93fbfef0b50354b7a1620822454ef29cd415cb2d
Author: Zhenlei Huang 
AuthorDate: 2024-05-20 12:14:07 +
Commit: Zhenlei Huang 
CommitDate: 2024-05-20 12:14:07 +

if_vxlan(4): Add checking for loops and nesting of tunnels

User misconfiguration, either tunnel loops, or a large number of
different nested tunnels, can overflow the kernel stack. Prevent that
by using if_tunnel_check_nesting().

PR: 278394
Diagnosed by:   markj
Reviewed by:kp
MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45197
---
 sys/net/if_vxlan.c | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/sys/net/if_vxlan.c b/sys/net/if_vxlan.c
index c6c3af57c78b..9153adf64cfc 100644
--- a/sys/net/if_vxlan.c
+++ b/sys/net/if_vxlan.c
@@ -432,6 +432,21 @@ TUNABLE_INT("net.link.vxlan.legacy_port", 
&vxlan_legacy_port);
 static int vxlan_reuse_port = 0;
 TUNABLE_INT("net.link.vxlan.reuse_port", &vxlan_reuse_port);
 
+/*
+ * This macro controls the default upper limitation on nesting of vxlan
+ * tunnels. By default it is 3, as the overhead of IPv6 vxlan tunnel is 70
+ * bytes, this will create at most 210 bytes overhead and the most inner
+ * tunnel's MTU will be 1290 which will meet IPv6 minimum MTU size 1280.
+ * Be careful to configure the tunnels when raising the limit. A large
+ * number of nested tunnels can introduce system crash.
+ */
+#ifndef MAX_VXLAN_NEST
+#define MAX_VXLAN_NEST 3
+#endif
+static int max_vxlan_nesting = MAX_VXLAN_NEST;
+SYSCTL_INT(_net_link_vxlan, OID_AUTO, max_nesting, CTLFLAG_RW,
+&max_vxlan_nesting, 0, "Max nested tunnels");
+
 /* Default maximum number of addresses in the forwarding table. */
 #ifndef VXLAN_FTABLE_MAX
 #define VXLAN_FTABLE_MAX   2000
@@ -2721,6 +2736,7 @@ vxlan_encap6(struct vxlan_softc *sc, const union 
vxlan_sockaddr *fvxlsa,
 #endif
 }
 
+#define MTAG_VXLAN_LOOP0x7876706c /* vxlp */
 static int
 vxlan_transmit(struct ifnet *ifp, struct mbuf *m)
 {
@@ -2746,6 +2762,13 @@ vxlan_transmit(struct ifnet *ifp, struct mbuf *m)
m_freem(m);
return (ENETDOWN);
}
+   if (__predict_false(if_tunnel_check_nesting(ifp, m, MTAG_VXLAN_LOOP,
+   max_vxlan_nesting) != 0)) {
+   VXLAN_RUNLOCK(sc, &tracker);
+   m_freem(m);
+   if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
+   return (ELOOP);
+   }
 
if ((m->m_flags & (M_BCAST | M_MCAST)) == 0)
fe = vxlan_ftable_entry_lookup(sc, eh->ether_dhost);



git: 76df3c57a0ab - main - ifconfig: Redo fix vlan/vlanproto reconfiguration

2024-05-21 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=76df3c57a0abfd24652bfa33982ba136d9d0575b

commit 76df3c57a0abfd24652bfa33982ba136d9d0575b
Author: Zhenlei Huang 
AuthorDate: 2024-05-21 16:35:01 +
Commit: Zhenlei Huang 
CommitDate: 2024-05-21 16:35:01 +

ifconfig: Redo fix vlan/vlanproto reconfiguration

When the if_vlan(4) interface has not been fully configured, i.e., a
bare interface without a physical interface associated with it,
retrieving the current settings of it and unconditionally overwriting
`params` will result in losing vlandev settings in `params`. That will
lead to failing to associate the if_vlan(4) interface with the requested
physical interface and the false report 'both vlan and vlandev must be
specified'.

Fix that by checking if the vlan interface has been fully configured.

The basic VLAN test is slightly modified to cover this case.

PR: 279181
Reviewed by:kp
Tested by:  Mike Tancsa 
Fixes:  b82b8055ad44 ifconfig: fix vlan/vlanproto reconfiguration
MFC after:  3 days
Differential Revision:  https://reviews.freebsd.org/D45283
---
 sbin/ifconfig/ifvlan.c   | 31 ++-
 tests/sys/net/if_vlan.sh | 10 +++---
 2 files changed, 33 insertions(+), 8 deletions(-)

diff --git a/sbin/ifconfig/ifvlan.c b/sbin/ifconfig/ifvlan.c
index a79ea35bc14b..0a2603f1736f 100644
--- a/sbin/ifconfig/ifvlan.c
+++ b/sbin/ifconfig/ifvlan.c
@@ -60,6 +60,7 @@
 #include "ifconfig.h"
 
 #defineNOTAG   ((u_short) -1)
+#defineNOPROTO ((u_short) -1)
 
 static const char proto_8021Q[]  = "802.1q";
 static const char proto_8021ad[] = "802.1ad";
@@ -67,7 +68,7 @@ static const char proto_qinq[] = "qinq";
 
 static struct vlanreq params = {
.vlr_tag= NOTAG,
-   .vlr_proto  = ETHERTYPE_VLAN,
+   .vlr_proto  = NOPROTO,
 };
 
 static void
@@ -157,6 +158,8 @@ vlan_create(if_ctx *ctx, struct ifreq *ifr)
errx(1, "must specify a tag for vlan create");
if (params.vlr_parent[0] == '\0')
errx(1, "must specify a parent device for vlan create");
+   if (params.vlr_proto == NOPROTO)
+   params.vlr_proto = ETHERTYPE_VLAN;
ifr->ifr_data = (caddr_t) ¶ms;
}
ifcreate_ioctl(ctx, ifr);
@@ -173,6 +176,8 @@ static void
 vlan_set(int s, struct ifreq *ifr)
 {
if (params.vlr_tag != NOTAG && params.vlr_parent[0] != '\0') {
+   if (params.vlr_proto == NOPROTO)
+   params.vlr_proto = ETHERTYPE_VLAN;
ifr->ifr_data = (caddr_t) ¶ms;
if (ioctl(s, SIOCSETVLAN, (caddr_t)ifr) == -1)
err(1, "SIOCSETVLAN");
@@ -196,8 +201,16 @@ setvlantag(if_ctx *ctx, const char *val, int dummy 
__unused)
errx(1, "value for vlan out of range");
 
if (ioctl_ctx_ifr(ctx, SIOCGETVLAN, &ifr) != -1) {
-   vreq.vlr_tag = params.vlr_tag;
-   memcpy(¶ms, &vreq, sizeof(params));
+   /*
+* Retrieve the current settings if the interface has already
+* been configured.
+*/
+   if (vreq.vlr_parent[0] != '\0') {
+   if (params.vlr_parent[0] == '\0')
+   strlcpy(params.vlr_parent, vreq.vlr_parent, 
IFNAMSIZ);
+   if (params.vlr_proto == NOPROTO)
+   params.vlr_proto = vreq.vlr_proto;
+   }
vlan_set(ctx->io_s, &ifr);
}
 }
@@ -230,8 +243,16 @@ setvlanproto(if_ctx *ctx, const char *val, int dummy 
__unused)
errx(1, "invalid value for vlanproto");
 
if (ioctl_ctx_ifr(ctx, SIOCGETVLAN, &ifr) != -1) {
-   vreq.vlr_proto = params.vlr_proto;
-   memcpy(¶ms, &vreq, sizeof(params));
+   /*
+* Retrieve the current settings if the interface has already
+* been configured.
+*/
+   if (vreq.vlr_parent[0] != '\0') {
+   if (params.vlr_parent[0] == '\0')
+   strlcpy(params.vlr_parent, vreq.vlr_parent, 
IFNAMSIZ);
+   if (params.vlr_tag == NOTAG)
+   params.vlr_tag = vreq.vlr_tag;
+   }
vlan_set(ctx->io_s, &ifr);
}
 }
diff --git a/tests/sys/net/if_vlan.sh b/tests/sys/net/if_vlan.sh
index 675ed0090e8c..458e3cc36bc6 100755
--- a/tests/sys/net/if_vlan.sh
+++ b/tests/sys/net/if_vlan.sh
@@ -22,8 +22,12 @@ basic_body()
jexec alcatraz ifco

git: d76ef58d566c - main - freebsd-update: Correctly check if pkg(8) is present

2024-05-22 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=d76ef58d566ccf203b21a1c8fea55985f355d4d2

commit d76ef58d566ccf203b21a1c8fea55985f355d4d2
Author: Zhenlei Huang 
AuthorDate: 2024-05-23 04:10:17 +
Commit: Zhenlei Huang 
CommitDate: 2024-05-23 04:10:17 +

freebsd-update: Correctly check if pkg(8) is present

On systems without pkg(8) installed, `command -v pkg` will return
success and falsely report that pkg(8) is present. Fix that by checking
via the `pkg -N` form.

This is missing from the final revision of D39695.

Reported by:delphij
Reviewed by:fernape, delphij
Fixes:  bc0c6c9cf3a9 freebsd-update: Add check for kernel modules
Differential Revision:  https://reviews.freebsd.org/D45292
---
 usr.sbin/freebsd-update/freebsd-update.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/usr.sbin/freebsd-update/freebsd-update.sh 
b/usr.sbin/freebsd-update/freebsd-update.sh
index fb9924ee60eb..1456601edf26 100644
--- a/usr.sbin/freebsd-update/freebsd-update.sh
+++ b/usr.sbin/freebsd-update/freebsd-update.sh
@@ -667,7 +667,7 @@ upgrade_check_kmod_ports() {
local report
local w
 
-   if ! command -v pkg >/dev/null; then
+   if ! pkg -N 2>/dev/null; then
echo "Skipping kernel modules check. pkg(8) not present."
return
fi



git: 2439ae948352 - main - mlx4, mlx5: Eliminate redundent NULL check for packet filter

2024-05-27 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=2439ae948352766f6b993c5103a4c516376bec28

commit 2439ae948352766f6b993c5103a4c516376bec28
Author: Zhenlei Huang 
AuthorDate: 2024-05-28 04:46:04 +
Commit: Zhenlei Huang 
CommitDate: 2024-05-28 04:46:04 +

mlx4, mlx5: Eliminate redundent NULL check for packet filter

mlx4 and mlx5 are Ethernet devices and ether_ifattach() does an
unconditional bpfattach(). From commit 16d878cc99ef [1] and on, we
should not check ifp->if_bpf to tell us whether or not we have any bpf
peers that might be interested in receiving packets. And since commit
2b9600b4497b [2], ifp->if_bpf can not be NULL even after the network
interface has been detached.

No functional change intended.

1. 16d878cc99ef Fix the following bpf(4) race condition which can result in 
a panic
2. 2b9600b4497b Add dead_bpf_if structure, that should be used as fake 
bpf_if during ifnet detach

Reviewed by:kp, kib
MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D45196
---
 sys/dev/mlx4/mlx4_en/mlx4_en_tx.c | 2 +-
 sys/dev/mlx5/mlx5_en/mlx5_en_tx.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/dev/mlx4/mlx4_en/mlx4_en_tx.c 
b/sys/dev/mlx4/mlx4_en/mlx4_en_tx.c
index 9a73c7571fd7..d45ccacd7499 100644
--- a/sys/dev/mlx4/mlx4_en/mlx4_en_tx.c
+++ b/sys/dev/mlx4/mlx4_en/mlx4_en_tx.c
@@ -688,7 +688,7 @@ int mlx4_en_xmit(struct mlx4_en_priv *priv, int tx_ind, 
struct mbuf **mbp)
dseg = &tx_desc->data;
 
/* send a copy of the frame to the BPF listener, if any */
-   if (ifp != NULL && if_getbpf(ifp) != NULL)
+   if (ifp != NULL)
ETHER_BPF_MTAP(ifp, mb);
 
/* get default flags */
diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c 
b/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c
index 1f2820abc30e..3f70e8a818ea 100644
--- a/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c
+++ b/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c
@@ -745,7 +745,7 @@ top:
mb = *mbp;
 
/* Send a copy of the frame to the BPF listener, if any */
-   if (ifp != NULL && if_getbpf(ifp) != NULL)
+   if (ifp != NULL)
ETHER_BPF_MTAP(ifp, mb);
 
if (mb->m_pkthdr.csum_flags & (CSUM_IP | CSUM_TSO)) {



git: 4eb82e65a73f - main - hidbus(4): Fix wrong assertion of bus

2024-06-05 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=4eb82e65a73f6cd180700bb8ae47227a553f94ed

commit 4eb82e65a73f6cd180700bb8ae47227a553f94ed
Author: Zhenlei Huang 
AuthorDate: 2024-06-05 12:03:27 +
Commit: Zhenlei Huang 
CommitDate: 2024-06-05 12:03:27 +

hidbus(4): Fix wrong assertion of bus

Reviewed by:wulf
Fixes:  4151ac9f1292 hidbus(4): Use generic hid methods to ...
MFC after:  3 days
Differential Revision:  https://reviews.freebsd.org/D45496
---
 sys/dev/hid/hidbus.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/dev/hid/hidbus.c b/sys/dev/hid/hidbus.c
index 99bfd7715c24..f50abd4b0a4d 100644
--- a/sys/dev/hid/hidbus.c
+++ b/sys/dev/hid/hidbus.c
@@ -604,7 +604,7 @@ hidbus_set_intr(device_t child, hid_intr_t *handler, void 
*context)
 static int
 hidbus_intr_start(device_t bus, device_t child)
 {
-   MPASS(bus = device_get_parent(child));
+   MPASS(bus == device_get_parent(child));
struct hidbus_softc *sc = device_get_softc(bus);
struct hidbus_ivars *ivar = device_get_ivars(child);
struct hidbus_ivars *tlc;
@@ -630,7 +630,7 @@ hidbus_intr_start(device_t bus, device_t child)
 static int
 hidbus_intr_stop(device_t bus, device_t child)
 {
-   MPASS(bus = device_get_parent(child));
+   MPASS(bus == device_get_parent(child));
struct hidbus_softc *sc = device_get_softc(bus);
struct hidbus_ivars *ivar = device_get_ivars(child);
struct hidbus_ivars *tlc;



git: 215a18d502cb - main - if_enc(4): Prefer the boolean form when calling bpf_peers_present()

2024-06-05 Thread Zhenlei Huang
The branch main has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=215a18d502cba2cf57251e82a84484219f2c432a

commit 215a18d502cba2cf57251e82a84484219f2c432a
Author: Zhenlei Huang 
AuthorDate: 2024-06-06 04:20:26 +
Commit: Zhenlei Huang 
CommitDate: 2024-06-06 04:20:26 +

if_enc(4): Prefer the boolean form when calling bpf_peers_present()

No functional change intended.

MFC after:  1 week
---
 sys/net/if_enc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/net/if_enc.c b/sys/net/if_enc.c
index 971afdabfff6..eaac0a843189 100644
--- a/sys/net/if_enc.c
+++ b/sys/net/if_enc.c
@@ -217,7 +217,7 @@ enc_bpftap(struct ifnet *ifp, struct mbuf *m, const struct 
secasvar *sav,
else if (hhook_type == HHOOK_TYPE_IPSEC_OUT &&
(enc & V_bpf_mask_out) == 0)
return;
-   if (bpf_peers_present(ifp->if_bpf) == 0)
+   if (!bpf_peers_present(ifp->if_bpf))
return;
hdr.af = af;
hdr.spi = sav->spi;



Re: git: 96ad640178ea - main - TCP LRO: add dtrace probe points

2024-03-08 Thread Zhenlei Huang



> On Mar 8, 2024, at 5:25 PM, Michael Tuexen  wrote:
> 
> The branch main has been updated by tuexen:
> 
> URL: 
> https://cgit.FreeBSD.org/src/commit/?id=96ad640178ea0a8a9d1772687659dce5be18fbd9
> 
> commit 96ad640178ea0a8a9d1772687659dce5be18fbd9
> Author: Michael Tuexen 
> AuthorDate: 2024-03-08 09:21:09 +
> Commit: Michael Tuexen 
> CommitDate: 2024-03-08 09:21:09 +
> 
>TCP LRO: add dtrace probe points
> 
>Add the IP, UDP, and TCP receive static probes to the code path,
>which avoids if_input.
> 
>Reviewed by:rrs, markj
>MFC after:  1 week`

Be aware the last character ` in meta message 'MFC after' . No idea whether the 
reminder mail
for MFCing will be correctly composed or not.

>Sponsored by:   Netflix, Inc.
>Differential Revision:  https://reviews.freebsd.org/D43727
> ---
> sys/netinet/tcp_lro_hpts.c | 44 
> 1 file changed, 44 insertions(+)
> 
> diff --git a/sys/netinet/tcp_lro_hpts.c b/sys/netinet/tcp_lro_hpts.c
> index 9c0d4be91d53..cd757d5a6164 100644
> --- a/sys/netinet/tcp_lro_hpts.c
> +++ b/sys/netinet/tcp_lro_hpts.c
> @@ -50,6 +50,7 @@
> #include 
> 
> #include 
> +#include 
> #include 
> #include 
> #include 
> @@ -281,22 +282,64 @@ do_bpf_strip_and_compress(struct tcpcb *tp, struct 
> lro_ctrl *lc,
>   case LRO_TYPE_IPV4_TCP:
>   tcp_hdr_offset -= sizeof(*le->outer.ip4);
>   m->m_pkthdr.lro_etype = ETHERTYPE_IP;
> + IP_PROBE(receive, NULL, NULL, le->outer.ip4, lc->ifp,
> + le->outer.ip4, NULL);
>   break;
>   case LRO_TYPE_IPV6_TCP:
>   tcp_hdr_offset -= sizeof(*le->outer.ip6);
>   m->m_pkthdr.lro_etype = ETHERTYPE_IPV6;
> + IP_PROBE(receive, NULL, NULL, le->outer.ip6, lc->ifp,
> + NULL, le->outer.ip6);
>   break;
>   default:
>   goto compressed;
>   }
>   break;
>   case LRO_TYPE_IPV4_TCP:
> + switch (le->outer.data.lro_type) {
> + case LRO_TYPE_IPV4_UDP:
> + IP_PROBE(receive, NULL, NULL, le->outer.ip4, lc->ifp,
> + le->outer.ip4, NULL);
> + UDP_PROBE(receive, NULL, NULL, le->outer.ip4, NULL,
> + le->outer.udp);
> + break;
> + case LRO_TYPE_IPV6_UDP:
> + IP_PROBE(receive, NULL, NULL, le->outer.ip6, lc->ifp,
> + NULL, le->outer.ip6);
> + UDP_PROBE(receive, NULL, NULL, le->outer.ip6, NULL,
> + le->outer.udp);
> + break;
> + default:
> + __assert_unreachable();
> + break;
> + }
>   tcp_hdr_offset -= sizeof(*le->outer.ip4);
>   m->m_pkthdr.lro_etype = ETHERTYPE_IP;
> + IP_PROBE(receive, NULL, NULL, le->inner.ip4, NULL,
> + le->inner.ip4, NULL);
>   break;
>   case LRO_TYPE_IPV6_TCP:
> + switch (le->outer.data.lro_type) {
> + case LRO_TYPE_IPV4_UDP:
> + IP_PROBE(receive, NULL, NULL, le->outer.ip4, lc->ifp,
> + le->outer.ip4, NULL);
> + UDP_PROBE(receive, NULL, NULL, le->outer.ip4, NULL,
> + le->outer.udp);
> + break;
> + case LRO_TYPE_IPV6_UDP:
> + IP_PROBE(receive, NULL, NULL, le->outer.ip6, lc->ifp,
> + NULL, le->outer.ip6);
> + UDP_PROBE(receive, NULL, NULL, le->outer.ip6, NULL,
> + le->outer.udp);
> + break;
> + default:
> + __assert_unreachable();
> + break;
> + }
>   tcp_hdr_offset -= sizeof(*le->outer.ip6);
>   m->m_pkthdr.lro_etype = ETHERTYPE_IPV6;
> + IP_PROBE(receive, NULL, NULL, le->inner.ip6, NULL, NULL,
> + le->inner.ip6);
>   break;
>   default:
>   goto compressed;
> @@ -313,6 +356,7 @@ do_bpf_strip_and_compress(struct tcpcb *tp, struct 
> lro_ctrl *lc,
> 
>   th->th_sum = 0; /* TCP checksum is valid. */
>   tcp_fields_to_host(th);
> + TCP_PROBE5(receive, NULL, tp, m, tp, th);
> 
>   /* Check if ACK can be compressed */
>   can_compress = tcp_lro_ack_valid(m, th, &ts_ptr, &other_opts);

Best regards,
Zhenlei




  1   2   3   4   >