From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7D6D18F40; Wed, 3 Sep 2025 01:08:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756861726; cv=none; b=ii9BiHXIoCI+z4k6xlHB78hwpD3ME/dPzRkd0dmycJEwgKPAUHOmAmXpOjsA+kPyDoVJOktAmup1vjMPsAli+uB+JrZcQzUHac4sSplcJ+TQUk6CYUCLUcR3SntMgnVjAkSF/EoavkkLWi994UUXr1Ehx8qLZ2BLBpQ7tKd+XiM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756861726; c=relaxed/simple; bh=e5/KG2RipKNRW/k1nCvd7VHEUkpw8jgjiB0Snb+ds8Q=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=htwGvGaXrPfzELC+bpJgYwkNjLCLIhXIU8DFb2qmsU27rhfAkYzGnaXutI2wEAujHIOlZ3Np0ZcayK8hTJJ2wJ5Dv7x1Nv7K5Hb7gKpP0u68pcszF38HfItFUoYNN82u6IPiRpvGXfLxgHLFukCgURZkOJBVn54rnnO9IHntYQ4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CUe7Uv97; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CUe7Uv97" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BA504C4CEED; Wed, 3 Sep 2025 01:08:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1756861726; bh=e5/KG2RipKNRW/k1nCvd7VHEUkpw8jgjiB0Snb+ds8Q=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=CUe7Uv97FS5VyuqhbVwuLouh53l4mEIm9t2KYiDIq1hERqtOeE2s/s3P6zxyrw2Th RpmMeylaTosN77vbs58h14A4hDRLuxxzlpPO4zCbXk4aLQkv19/loiJ8SAZxlKyhN1 bsUroR3uapE639Jn1uwmILBPs9zZL3RroS8MwHunuFHdw5vWZVRan/WGXD40SGBaY6 8SGTAjxgbiq0H+xWc52vKqdDwUoTUdTRzlmyhfNchA96EPbuB57AnDtk6ZMJon2Qsb 9rxCyuaV2J6vfdrcb5nlmSO3LpgRX7LUA8cVh1qbHTQUhGhNtdETq6HXWDYEJbW/Ju lcJ8PGk7XL31g== Date: Tue, 2 Sep 2025 18:08:43 -0700 From: Jakub Kicinski To: Fan Gong Cc: Zhu Yikai , , , "David S. Miller" , Eric Dumazet , Paolo Abeni , Simon Horman , Andrew Lunn , , Jonathan Corbet , Bjorn Helgaas , luosifu , Xin Guo , Shen Chenyang , Zhou Shuai , Wu Like , Shi Jing , Meny Yossefi , Gur Stavi , Lee Trager , Michael Ellerman , Vadim Fedorenko , Suman Ghosh , Przemek Kitszel , Joe Damato , Christophe JAILLET Subject: Re: [PATCH net-next v03 02/14] hinic3: HW management interfaces Message-ID: <20250902180843.5ba05bf2@kernel.org> In-Reply-To: <07e099c1395b725d880900550eaceb44a189d901.1756524443.git.zhuyikai1@h-partners.com> References: <07e099c1395b725d880900550eaceb44a189d901.1756524443.git.zhuyikai1@h-partners.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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).