Thread (22 messages) 22 messages, 2 authors, 2025-09-03

Re: [PATCH net-next v03 02/14] hinic3: HW management interfaces

From: Jakub Kicinski <kuba@kernel.org>
Date: 2025-09-03 01:08:46
Also in: linux-doc, lkml

On Sat, 30 Aug 2025 16:08:41 +0800 Fan Gong wrote:
+int hinic3_init_cfg_mgmt(struct hinic3_hwdev *hwdev)
+{
+	struct hinic3_cfg_mgmt_info *cfg_mgmt;
+	int err;
+
+	if (!hwdev->hwif->attr.num_ceqs) {
+		dev_err(hwdev->dev, "Ceq num cfg in fw is zero\n");
+		return -EINVAL;
+	}
The input checking in most of the functions looks like defensive
programming. The values should be checked when they are set / loaded,
not on input to random functions. Defensive programming should be
avoided in the kernel (meaning, unless you can point out actual callers
which need the validation, and can explain why doing the check in the
callee rather than the caller is cleaner -- the check should be in the
caller).
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help