[Mesa-dev] [PATCH 05/13] pipe-loader: handle memory allocation failure
Francisco Jerez
currojerez at riseup.net
Thu Feb 13 04:53:28 PST 2014
Emil Velikov <emil.l.velikov at gmail.com> writes:
> Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
> ---
> src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c | 3 +++
> src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c | 1 +
> 2 files changed, 4 insertions(+)
>
> diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
> index 16f8a58..c5f191f 100644
> --- a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
> +++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
> @@ -118,6 +118,9 @@ pipe_loader_drm_probe_fd(struct pipe_loader_device **dev, int fd)
> struct pipe_loader_drm_device *ddev = CALLOC_STRUCT(pipe_loader_drm_device);
> int vendor_id, chip_id;
>
> + if (!ddev)
> + return FALSE;
> +
> if (loader_get_pci_id_for_fd(fd, &vendor_id, &chip_id)) {
> ddev->base.type = PIPE_LOADER_DEVICE_PCI;
> ddev->base.u.pci.vendor_id = vendor_id;
> diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c b/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
> index fd3d989..7f3f93b 100644
> --- a/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
> +++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
> @@ -58,6 +58,7 @@ pipe_loader_sw_probe(struct pipe_loader_device **devs, int ndev)
> for (i = 0; i < Elements(backends); i++) {
> if (i < ndev) {
> struct pipe_loader_sw_device *sdev = CALLOC_STRUCT(pipe_loader_sw_device);
> + /* TODO: handle CALLOC_STRUCT failure */
We could use separate counters for the backends[] and devs[] array, and
only increment the latter if the memory allocation/initialization
succeeds (and if 'i >= ndev'). Or just get rid of this function.
Either way this patch is:
Reviewed-by: Francisco Jerez <currojerez at riseup.net>
>
> sdev->base.type = PIPE_LOADER_DEVICE_SOFTWARE;
> sdev->base.driver_name = "swrast";
> --
> 1.8.5.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 229 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20140213/9be546ce/attachment.pgp>
More information about the mesa-dev
mailing list