gve: Avoid freeing NULL pointer
[ Upstream commit 922aa9bcac92b3ab6a423526a8e785b35a60b441 ]
Prevent possible crashes when cleaning up after unsuccessful
initializations.
Fixes: 893ce44df5
("gve: Add basic driver framework for Compute Engine Virtual NIC")
Signed-off-by: Tao Liu <xliutaox@google.com>
Signed-off-by: Catherine Sully <csully@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
5d903a694b
commit
72c2a68f1d
@@ -71,6 +71,9 @@ static int gve_alloc_counter_array(struct gve_priv *priv)
|
|||||||
|
|
||||||
static void gve_free_counter_array(struct gve_priv *priv)
|
static void gve_free_counter_array(struct gve_priv *priv)
|
||||||
{
|
{
|
||||||
|
if (!priv->counter_array)
|
||||||
|
return;
|
||||||
|
|
||||||
dma_free_coherent(&priv->pdev->dev,
|
dma_free_coherent(&priv->pdev->dev,
|
||||||
priv->num_event_counters *
|
priv->num_event_counters *
|
||||||
sizeof(*priv->counter_array),
|
sizeof(*priv->counter_array),
|
||||||
@@ -131,6 +134,9 @@ static int gve_alloc_stats_report(struct gve_priv *priv)
|
|||||||
|
|
||||||
static void gve_free_stats_report(struct gve_priv *priv)
|
static void gve_free_stats_report(struct gve_priv *priv)
|
||||||
{
|
{
|
||||||
|
if (!priv->stats_report)
|
||||||
|
return;
|
||||||
|
|
||||||
del_timer_sync(&priv->stats_report_timer);
|
del_timer_sync(&priv->stats_report_timer);
|
||||||
dma_free_coherent(&priv->pdev->dev, priv->stats_report_len,
|
dma_free_coherent(&priv->pdev->dev, priv->stats_report_len,
|
||||||
priv->stats_report, priv->stats_report_bus);
|
priv->stats_report, priv->stats_report_bus);
|
||||||
@@ -301,7 +307,9 @@ static void gve_free_notify_blocks(struct gve_priv *priv)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (priv->msix_vectors) {
|
if (!priv->msix_vectors)
|
||||||
|
return;
|
||||||
|
|
||||||
/* Free the irqs */
|
/* Free the irqs */
|
||||||
for (i = 0; i < priv->num_ntfy_blks; i++) {
|
for (i = 0; i < priv->num_ntfy_blks; i++) {
|
||||||
struct gve_notify_block *block = &priv->ntfy_blocks[i];
|
struct gve_notify_block *block = &priv->ntfy_blocks[i];
|
||||||
@@ -312,7 +320,6 @@ static void gve_free_notify_blocks(struct gve_priv *priv)
|
|||||||
free_irq(priv->msix_vectors[msix_idx].vector, block);
|
free_irq(priv->msix_vectors[msix_idx].vector, block);
|
||||||
}
|
}
|
||||||
free_irq(priv->msix_vectors[priv->mgmt_msix_idx].vector, priv);
|
free_irq(priv->msix_vectors[priv->mgmt_msix_idx].vector, priv);
|
||||||
}
|
|
||||||
dma_free_coherent(&priv->pdev->dev,
|
dma_free_coherent(&priv->pdev->dev,
|
||||||
priv->num_ntfy_blks * sizeof(*priv->ntfy_blocks),
|
priv->num_ntfy_blks * sizeof(*priv->ntfy_blocks),
|
||||||
priv->ntfy_blocks, priv->ntfy_block_bus);
|
priv->ntfy_blocks, priv->ntfy_block_bus);
|
||||||
|
Reference in New Issue
Block a user