[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <baf5ac2e-87a2-c2e1-2b61-aae668b10881@intel.com>
Date: Thu, 13 Apr 2023 12:10:01 -0700
From: "Tantilov, Emil S" <emil.s.tantilov@...el.com>
To: Simon Horman <simon.horman@...igine.com>,
Pavan Kumar Linga <pavan.kumar.linga@...el.com>
CC: <intel-wired-lan@...ts.osuosl.org>, <netdev@...r.kernel.org>,
<joshua.a.hay@...el.com>, <sridhar.samudrala@...el.com>,
<jesse.brandeburg@...el.com>, <anthony.l.nguyen@...el.com>,
<willemb@...gle.com>, <decot@...gle.com>, <pabeni@...hat.com>,
<kuba@...nel.org>, <edumazet@...gle.com>, <davem@...emloft.net>,
Alan Brady <alan.brady@...el.com>,
Madhu Chittim <madhu.chittim@...el.com>,
Phani Burra <phani.r.burra@...el.com>,
Shailendra Bhatnagar <shailendra.bhatnagar@...el.com>
Subject: Re: [PATCH net-next v2 04/15] idpf: add core init and interrupt
request
On 4/11/2023 2:52 AM, Simon Horman wrote:
> On Mon, Apr 10, 2023 at 06:13:43PM -0700, Pavan Kumar Linga wrote:
>
> ...
>
>> diff --git a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
>
> ...
>
>> +/**
>> + * idpf_recv_get_caps_msg - Receive virtchnl get capabilities message
>> + * @adapter: Driver specific private structure
>> + *
>> + * Receive virtchnl get capabilities message. Returns 0 on success, negative on
>> + * failure.
>> + */
>> +static int idpf_recv_get_caps_msg(struct idpf_adapter *adapter)
>> +{
>> + return idpf_recv_mb_msg(adapter, VIRTCHNL2_OP_GET_CAPS, &adapter->caps,
>> + sizeof(struct virtchnl2_get_capabilities));
>> +}
>> +
>> +/**
>> + * idpf_send_alloc_vectors_msg - Send virtchnl alloc vectors message
>> + * @adapter: Driver specific private structure
>> + * @num_vectors: number of vectors to be allocated
>> + *
>> + * Returns 0 on success, negative on failure.
>> + */
>> +int idpf_send_alloc_vectors_msg(struct idpf_adapter *adapter, u16 num_vectors)
>> +{
>> + struct virtchnl2_alloc_vectors *alloc_vec, *rcvd_vec;
>> + struct virtchnl2_alloc_vectors ac = { };
>> + u16 num_vchunks;
>> + int size, err;
>> +
>> + ac.num_vectors = cpu_to_le16(num_vectors);
>> +
>> + err = idpf_send_mb_msg(adapter, VIRTCHNL2_OP_ALLOC_VECTORS,
>> + sizeof(ac), (u8 *)&ac);
>> + if (err)
>> + return err;
>> +
>> + err = idpf_wait_for_event(adapter, NULL, IDPF_VC_ALLOC_VECTORS,
>> + IDPF_VC_ALLOC_VECTORS_ERR);
>> + if (err)
>> + return err;
>> +
>> + rcvd_vec = (struct virtchnl2_alloc_vectors *)adapter->vc_msg;
>> + num_vchunks = le16_to_cpu(rcvd_vec->vchunks.num_vchunks);
>> +
>> + size = struct_size(rcvd_vec, vchunks.vchunks, num_vchunks);
>> + if (size > sizeof(adapter->vc_msg)) {
>> + err = -EINVAL;
>> + goto error;
>> + }
>> +
>> + kfree(adapter->req_vec_chunks);
>> + adapter->req_vec_chunks = NULL;
>> + adapter->req_vec_chunks = kzalloc(size, GFP_KERNEL);
>> + if (!adapter->req_vec_chunks) {
>> + err = -ENOMEM;
>> + goto error;
>> + }
>> + memcpy(adapter->req_vec_chunks, adapter->vc_msg, size);
>
> Hi Pavan,
>
> Coccinelle suggests that kmemdup might be used here.
>
> drivers/net/ethernet/intel/idpf/idpf_virtchnl.c:2085:27-34: WARNING opportunity for kmemdup
>
> Likewise for a similar pattern in:
> * [PATCH net-next v2 14/15] idpf: add ethtool callbacks
>
> ...
We'll address it in v3.
Thanks,
Emil
Powered by blists - more mailing lists