diff --git a/drivers/pci/access.c b/drivers/pci/access.c
index 381444794778fb02e050dfb548eba78b42f6117b..64dd7df90e620a327e2d9f84f72af71cee7eedf3 100644
--- a/drivers/pci/access.c
+++ b/drivers/pci/access.c
@@ -356,7 +356,8 @@ int pci_vpd_truncate(struct pci_dev *dev, size_t size)
 		return -EINVAL;
 
 	dev->vpd->len = size;
-	dev->vpd->attr->size = size;
+	if (dev->vpd->attr)
+		dev->vpd->attr->size = size;
 
 	return 0;
 }