[Mesa-dev] [PATCH 2/7] st/xorg: add sanity checks after malloc

Brian Paul brianp at vmware.com
Mon Sep 30 07:35:25 PDT 2013


On 09/28/2013 08:46 AM, Emil Velikov wrote:
> Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
> ---
>   src/gallium/state_trackers/xorg/xorg_driver.c | 6 ++++++
>   1 file changed, 6 insertions(+)
>
> diff --git a/src/gallium/state_trackers/xorg/xorg_driver.c b/src/gallium/state_trackers/xorg/xorg_driver.c
> index dd243bc..097c354 100644
> --- a/src/gallium/state_trackers/xorg/xorg_driver.c
> +++ b/src/gallium/state_trackers/xorg/xorg_driver.c
> @@ -124,6 +124,9 @@ Bool
>   xorg_tracker_have_modesetting(ScrnInfoPtr pScrn, struct pci_device *device)
>   {
>       char *BusID = malloc(64);
> +
> +    if (!BusID)
> +	return FALSE;
>       sprintf(BusID, "pci:%04x:%02x:%02x.%d",
>   	    device->domain, device->bus,
>   	    device->dev, device->func);
> @@ -276,6 +279,9 @@ drv_init_drm(ScrnInfoPtr pScrn)
>   	char *BusID;
>
>   	BusID = malloc(64);
> +	if (!BusID)
> +	    return FALSE;
> +
>   	sprintf(BusID, "PCI:%d:%d:%d",
>   		((ms->PciInfo->domain << 8) | ms->PciInfo->bus),
>   		ms->PciInfo->dev, ms->PciInfo->func
>

Reviewed-by: Brian Paul <brianp at vmware.com>



More information about the mesa-dev mailing list