Skip to content

Commit

Permalink
misc: alcor_pci: set NULL intfdata and clear pci master
Browse files Browse the repository at this point in the history
alcor_pci doesn't set driver data to NULL and clear pci master when
probe fails. Doesn't clear pci master from remove interface. Clearing
pci master is necessary to disable bus mastering and prevent DMAs after
driver removal.

Fix alcor_pci_probe() to set driver data to NULL and clear pci master
from its error path. Fix alcor_pci_remove() to clear pci master.

Signed-off-by: Shuah Khan <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
shuahkh authored and gregkh committed May 19, 2022
1 parent 5621a0b commit 8e04a7a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion drivers/misc/cardreader/alcor_pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,12 +317,15 @@ static int alcor_pci_probe(struct pci_dev *pdev,
ret = mfd_add_devices(&pdev->dev, priv->id, alcor_pci_cells,
ARRAY_SIZE(alcor_pci_cells), NULL, 0, NULL);
if (ret < 0)
goto error_release_regions;
goto error_clear_drvdata;

alcor_pci_aspm_ctrl(priv, 0);

return 0;

error_clear_drvdata:
pci_clear_master(pdev);
pci_set_drvdata(pdev, NULL);
error_release_regions:
pci_release_regions(pdev);
error_free_ida:
Expand All @@ -343,6 +346,7 @@ static void alcor_pci_remove(struct pci_dev *pdev)
ida_free(&alcor_pci_idr, priv->id);

pci_release_regions(pdev);
pci_clear_master(pdev);
pci_set_drvdata(pdev, NULL);
}

Expand Down

0 comments on commit 8e04a7a

Please sign in to comment.