Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8eb81fae authored by Lakshit Tyagi's avatar Lakshit Tyagi
Browse files

data-kernel: EMAC: ETH KW Errors solved



- Added check for NULL pointer access and initialized  uninitalized variables.

Change-Id: I84dfee37664407fd5a7d1303b0457ea241130cea
Acked-by : Sneh Shah <snehshah@qti.qualcomm.com>
Signed-off-by: default avatarMohammed Javid <mjavid@codeaurora.org>
parent 56712624
Loading
Loading
Loading
Loading
+67 −55
Original line number Diff line number Diff line
@@ -3117,11 +3117,12 @@ static void DWC_ETH_QOS_consume_page_split_hdr(
{
	if (page2_used)
		buffer->page2 = NULL;

		if (skb != NULL) {
			skb->len += length;
			skb->data_len += length;
			skb->truesize += length;
		}
}

/* Receive Checksum Offload configuration */
static inline void DWC_ETH_QOS_config_rx_csum(struct DWC_ETH_QOS_prv_data *pdata,
@@ -3228,7 +3229,7 @@ static int DWC_ETH_QOS_clean_split_hdr_rx_irq(
	unsigned short payload_len = 0;
	unsigned char intermediate_desc_cnt = 0;
	unsigned char buf2_used = 0;
	int ret;
	int ret = 0;

	DBGPR("-->DWC_ETH_QOS_clean_split_hdr_rx_irq: qinx = %u, quota = %d\n",
	      qinx, quota);
@@ -3327,14 +3328,12 @@ static int DWC_ETH_QOS_clean_split_hdr_rx_irq(
				} else {
					/* this is the middle of a chain */
					payload_len = pdata->rx_buffer_len;
					skb_fill_page_desc(desc_data->skb_top,
							   skb_shinfo(desc_data->skb_top)->nr_frags,
						buffer->page2, 0,
						payload_len);

					if (desc_data->skb_top != NULL)
						skb_fill_page_desc(desc_data->skb_top,skb_shinfo(desc_data->skb_top)->nr_frags,buffer->page2, 0,payload_len);
					/* re-use this skb, as consumed only the page */
					buffer->skb = skb;
				}
				if (desc_data->skb_top != NULL)
						DWC_ETH_QOS_consume_page_split_hdr(buffer,
								   desc_data->skb_top,
							 payload_len, buf2_used);
@@ -3352,16 +3351,14 @@ static int DWC_ETH_QOS_clean_split_hdr_rx_irq(
							(pdata->rx_buffer_len * intermediate_desc_cnt) -
							buffer->rx_hdr_size);
					}

					skb_fill_page_desc(desc_data->skb_top,
							   skb_shinfo(desc_data->skb_top)->nr_frags,
						buffer->page2, 0,
						payload_len);

					if (desc_data->skb_top != NULL) {
						skb_fill_page_desc(desc_data->skb_top,skb_shinfo(desc_data->skb_top)->nr_frags,buffer->page2, 0,payload_len);
						/* re-use this skb, as consumed only the page */
						buffer->skb = skb;
						skb = desc_data->skb_top;
					}
					desc_data->skb_top = NULL;
					if (skb != NULL)
						DWC_ETH_QOS_consume_page_split_hdr(buffer, skb,
									   payload_len, buf2_used);
				} else {
@@ -3406,11 +3403,13 @@ static int DWC_ETH_QOS_clean_split_hdr_rx_irq(
				hdr_len = 0;
			}

			if (skb != NULL) {
				DWC_ETH_QOS_config_rx_csum(pdata, skb, RX_NORMAL_DESC);

#ifdef DWC_ETH_QOS_ENABLE_VLAN_TAG
				DWC_ETH_QOS_get_rx_vlan(pdata, skb, RX_NORMAL_DESC);
#endif
			}

#ifdef YDEBUG_FILTER
			DWC_ETH_QOS_check_rx_filter_status(RX_NORMAL_DESC);
@@ -3419,6 +3418,7 @@ static int DWC_ETH_QOS_clean_split_hdr_rx_irq(
			if ((pdata->hw_feat.tsstssel) && (pdata->hwts_rx_en)) {
				/* get rx tstamp if available */
				if (hw_if->rx_tstamp_available(RX_NORMAL_DESC)) {
					if (skb != NULL )
						ret = DWC_ETH_QOS_get_rx_hwtstamp(pdata,
									  skb, desc_data, qinx);
					if (ret == 0) {
@@ -3426,6 +3426,7 @@ static int DWC_ETH_QOS_clean_split_hdr_rx_irq(
						 * time stamp, hence delay the packet reception
						 */
						buffer->skb = skb;
						if (skb != NULL)
							buffer->dma = dma_map_single(GET_MEM_PDEV_DEV, skb->data,
								pdata->rx_buffer_len, DMA_FROM_DEVICE);
						if (dma_mapping_error(GET_MEM_PDEV_DEV, buffer->dma))
@@ -3446,8 +3447,10 @@ static int DWC_ETH_QOS_clean_split_hdr_rx_irq(
#endif
			/* update the statistics */
			dev->stats.rx_packets++;
			if ( skb != NULL) {
				dev->stats.rx_bytes += skb->len;
				DWC_ETH_QOS_receive_skb(pdata, dev, skb, qinx);
			}
			received++;
 next_desc:
			desc_data->dirty_rx++;
@@ -3508,7 +3511,7 @@ static int DWC_ETH_QOS_clean_jumbo_rx_irq(struct DWC_ETH_QOS_prv_data *pdata,
	u16 pkt_len;
	UCHAR intermediate_desc_cnt = 0;
	unsigned int buf2_used;
	int ret;
	int ret = 0 ;

	DBGPR("-->DWC_ETH_QOS_clean_jumbo_rx_irq: qinx = %u, quota = %d\n",
	      qinx, quota);
@@ -3579,19 +3582,21 @@ static int DWC_ETH_QOS_clean_jumbo_rx_irq(struct DWC_ETH_QOS_prv_data *pdata,
						pdata->rx_buffer_len);
				} else {
					/* this is the middle of a chain */
					if (desc_data->skb_top != NULL) {
						skb_fill_page_desc(desc_data->skb_top,
							   skb_shinfo(desc_data->skb_top)->nr_frags,
						buffer->page, 0,
						pdata->rx_buffer_len);

						DBGPR("RX: pkt in second buffer pointer\n");
						skb_fill_page_desc(desc_data->skb_top,
							   skb_shinfo(desc_data->skb_top)->nr_frags,
						buffer->page2, 0,
						pdata->rx_buffer_len);
					}
					/* re-use this skb, as consumed only the page */
					buffer->skb = skb;
				}
				if (desc_data->skb_top != NULL )
					DWC_ETH_QOS_consume_page(buffer,
							 desc_data->skb_top,
							 (pdata->rx_buffer_len * 2),
@@ -3603,18 +3608,20 @@ static int DWC_ETH_QOS_clean_jumbo_rx_irq(struct DWC_ETH_QOS_prv_data *pdata,
					pkt_len =
						(pkt_len - (pdata->rx_buffer_len * intermediate_desc_cnt));
					if (pkt_len > pdata->rx_buffer_len) {
						if (desc_data->skb_top != NULL) {
							skb_fill_page_desc(desc_data->skb_top,
								   skb_shinfo(desc_data->skb_top)->nr_frags,
							buffer->page, 0,
							pdata->rx_buffer_len);

							DBGPR("RX: pkt in second buffer pointer\n");
							skb_fill_page_desc(desc_data->skb_top,
								   skb_shinfo(desc_data->skb_top)->nr_frags,
							buffer->page2, 0,
							(pkt_len - pdata->rx_buffer_len));
						}
						buf2_used = 1;
					} else {
						if (desc_data->skb_top != NULL)
							skb_fill_page_desc(desc_data->skb_top,
								   skb_shinfo(desc_data->skb_top)->nr_frags,
							buffer->page, 0,
@@ -3623,8 +3630,10 @@ static int DWC_ETH_QOS_clean_jumbo_rx_irq(struct DWC_ETH_QOS_prv_data *pdata,
					}
					/* re-use this skb, as consumed only the page */
					buffer->skb = skb;
					if (desc_data->skb_top != NULL)
						skb = desc_data->skb_top;
					desc_data->skb_top = NULL;
					if (skb != NULL)
						DWC_ETH_QOS_consume_page(buffer, skb,
								 pkt_len,
								 buf2_used);
@@ -3675,11 +3684,13 @@ static int DWC_ETH_QOS_clean_jumbo_rx_irq(struct DWC_ETH_QOS_prv_data *pdata,
				intermediate_desc_cnt = 0;
			}

			if (skb != NULL) {
				DWC_ETH_QOS_config_rx_csum(pdata, skb, RX_NORMAL_DESC);

#ifdef DWC_ETH_QOS_ENABLE_VLAN_TAG
				DWC_ETH_QOS_get_rx_vlan(pdata, skb, RX_NORMAL_DESC);
#endif
			}

#ifdef YDEBUG_FILTER
			DWC_ETH_QOS_check_rx_filter_status(RX_NORMAL_DESC);
@@ -3688,15 +3699,16 @@ static int DWC_ETH_QOS_clean_jumbo_rx_irq(struct DWC_ETH_QOS_prv_data *pdata,
			if ((pdata->hw_feat.tsstssel) && (pdata->hwts_rx_en)) {
				/* get rx tstamp if available */
				if (hw_if->rx_tstamp_available(RX_NORMAL_DESC)) {
					ret = DWC_ETH_QOS_get_rx_hwtstamp(pdata,
									  skb, desc_data, qinx);
					if (skb != NULL)
						ret = DWC_ETH_QOS_get_rx_hwtstamp(pdata, skb, desc_data, qinx);
					if (ret == 0) {
						/* device has not yet updated the CONTEXT desc to hold the
						 * time stamp, hence delay the packet reception
						 */
						buffer->skb = skb;
						buffer->dma = dma_map_single(GET_MEM_PDEV_DEV, skb->data,
								pdata->rx_buffer_len, DMA_FROM_DEVICE);
						if (skb != NULL)
							buffer->dma = dma_map_single(GET_MEM_PDEV_DEV, skb->data, pdata->rx_buffer_len, DMA_FROM_DEVICE);

						if (dma_mapping_error(GET_MEM_PDEV_DEV, buffer->dma))
							dev_alert(&pdata->pdev->dev, "failed to do the RX dma map\n");

@@ -3716,16 +3728,16 @@ static int DWC_ETH_QOS_clean_jumbo_rx_irq(struct DWC_ETH_QOS_prv_data *pdata,
#endif
			/* update the statistics */
			dev->stats.rx_packets++;
			if (skb != NULL) {
				dev->stats.rx_bytes += skb->len;

				/* eth type trans needs skb->data to point to something */
				if (!pskb_may_pull(skb, ETH_HLEN)) {
					dev_alert(&pdata->pdev->dev, "pskb_may_pull failed\n");
					dev_kfree_skb_any(skb);
					goto next_desc;
				}

				DWC_ETH_QOS_receive_skb(pdata, dev, skb, qinx);
			}
			received++;
 next_desc:
			desc_data->dirty_rx++;
+3 −3
Original line number Diff line number Diff line
@@ -525,7 +525,7 @@ static int DWC_ETH_QOS_ipa_offload_resume(struct DWC_ETH_QOS_prv_data *pdata)

static int DWC_ETH_QOS_ipa_ready(struct DWC_ETH_QOS_prv_data *pdata)
{
	int ret;
	int ret = 0 ;

	EMACDBG("Enter \n");

@@ -960,8 +960,8 @@ static int DWC_ETH_QOS_ipa_offload_connect(struct DWC_ETH_QOS_prv_data *pdata)
	struct DWC_ETH_QOS_prv_ipa_data *ntn_ipa = &pdata->prv_ipa;
	struct ipa_uc_offload_conn_in_params in;
	struct ipa_uc_offload_conn_out_params out;
	struct ipa_ntn_setup_info rx_setup_info;
	struct ipa_ntn_setup_info tx_setup_info;
	struct ipa_ntn_setup_info rx_setup_info = {0};
	struct ipa_ntn_setup_info tx_setup_info = {0};
	struct ipa_perf_profile profile;
	int ret = 0;
	int i = 0;
+1 −1
Original line number Diff line number Diff line
@@ -969,7 +969,7 @@ int DWC_ETH_QOS_qmp_mailbox_init(struct DWC_ETH_QOS_prv_data *pdata)
	pdata->qmp_mbox_client = devm_kzalloc(
	   &pdata->pdev->dev, sizeof(*pdata->qmp_mbox_client), GFP_KERNEL);

	if (IS_ERR(pdata->qmp_mbox_client)){
	if (pdata->qmp_mbox_client == NULL || IS_ERR(pdata->qmp_mbox_client)){
		EMACERR("qmp alloc client failed\n");
		return -1;
	}