tty: vcc: Add check for kstrdup() in vcc_probe()
Subsystems (3)
Sasha Levin
maintainerPATCH 1/2 tty: vcc: Add check for kstrdup() in vcc_probe()
From: Yi Yang <[email protected]>
[ Upstream commit d81ffb87aaa75f842cd7aa57091810353755b3e6 ]
Add check for the return value of kstrdup() and return the error, if it fails in order to avoid NULL pointer dereference.
--- drivers/tty/vcc.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/tty/vcc.c +13 -3
@@ -594,18 +594,22 @@ static int vcc_probe(struct vio_dev *vdev, const struct vio_device_id *id)return -ENOMEM ; name =kstrdup (dev_name (&vdev->dev),GFP_KERNEL ); +if (!name) { + rv = -ENOMEM ; + goto free_port; + } rv =vio_driver_init (&port->vio, vdev,VDEV_CONSOLE_CON , vcc_versions,ARRAY_SIZE (vcc_versions),NULL , name);if (rv) - goto free_port; + goto free_name; port->vio.debug = vcc_dbg_vio; vcc_ldc_cfg.debug = vcc_dbg_ldc; rv =vio_ldc_alloc (&port->vio, &vcc_ldc_cfg, port);if (rv) - goto free_port; + goto free_name;spin_lock_init (&port->lock);
@@ -639,6 +643,11 @@ static int vcc_probe(struct vio_dev *vdev, const struct vio_device_id *id) goto unreg_tty; } port->domain =kstrdup (domain,GFP_KERNEL ); +if (!port->domain) { + rv = -ENOMEM ; + goto unreg_tty; + } +mdesc_release (hp);
@@ -673,8 +682,9 @@ static int vcc_probe(struct vio_dev *vdev, const struct vio_device_id *id)vcc_table_remove (port->index); free_ldc:vio_ldc_free (&port->vio); -free_port: +free_name:kfree (name); +free_port:kfree (port);return rv;
Signature · 1 line
2.42.0
Sasha Levin
maintainerPATCH 2/2 usb: pci-quirks: handle HAS_IOPORT dependency for UHCI handoff
From: Niklas Schnelle <[email protected]>
[ Upstream commit 358ad297e379ff548247e3e24c6619559942bfdd ]
In a future patch HAS_IOPORT=n will result in inb()/outb() and friends not being declared. With the AMD quirk handled USB PCI quirks still use inw() in uhci_check_and_reset_hc() and thus indirectly in quirk_usb_handoff_uhci(). Handle this by conditionally compiling uhci_check_and_reset_hc() and stubbing out quirk_usb_handoff_uhci() when HAS_IOPORT is not available.
--- drivers/usb/host/pci-quirks.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-)
drivers/usb/host/pci-quirks.c +16 -7
@@ -627,6 +627,16 @@ bool usb_amd_pt_check_port(struct device *device, int port) }EXPORT_SYMBOL_GPL (usb_amd_pt_check_port); +static inline int io_type_enabled (struct pci_dev *pdev,unsigned int mask) +{ +u16 cmd; + +return !pci_read_config_word (pdev,PCI_COMMAND , &cmd) && (cmd & mask); +} + +#define mmio_enabled (dev) io_type_enabled(dev, PCI_COMMAND_MEMORY) + +#if defined(CONFIG_HAS_IOPORT ) &&IS_ENABLED (CONFIG_USB_UHCI_HCD )/* * Make sure the controller is completely inactive, unable to * generate interrupts or do DMA.
@@ -708,14 +718,7 @@ int uhci_check_and_reset_hc(struct pci_dev *pdev, unsigned long base) }EXPORT_SYMBOL_GPL (uhci_check_and_reset_hc); -static inline int io_type_enabled (struct pci_dev *pdev,unsigned int mask) -{ -u16 cmd; -return !pci_read_config_word (pdev,PCI_COMMAND , &cmd) && (cmd & mask); -} -#define pio_enabled (dev) io_type_enabled(dev, PCI_COMMAND_IO) -#define mmio_enabled (dev) io_type_enabled(dev, PCI_COMMAND_MEMORY)static void quirk_usb_handoff_uhci (struct pci_dev *pdev) {
@@ -735,6 +738,12 @@ static void quirk_usb_handoff_uhci(struct pci_dev *pdev) uhci_check_and_reset_hc(pdev, base); } +#else /* defined(CONFIG_HAS_IOPORT && IS_ENABLED(CONFIG_USB_UHCI_HCD) */ + +static void quirk_usb_handoff_uhci (struct pci_dev *pdev) {} + +#endif /* defined(CONFIG_HAS_IOPORT && IS_ENABLED(CONFIG_USB_UHCI_HCD) */ +static int mmio_resource_enabled (struct pci_dev *pdev,int idx) {return pci_resource_start (pdev, idx) &&mmio_enabled (pdev);
Signature · 1 line
2.42.0