Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 01b1d975 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab
Browse files

[media] vpif_display: fix cleanup code



The cleanup sequence was incorrect and could cause a kernel oops.

Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Acked-by: default avatarLad, Prabhakar <prabhakar.lad@ti.com>
Tested-by: default avatarLad, Prabhakar <prabhakar.lad@ti.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent e6067f8b
Loading
Loading
Loading
Loading
+20 −13
Original line number Original line Diff line number Diff line
@@ -1607,7 +1607,8 @@ static __init int vpif_probe(struct platform_device *pdev)
{
{
	struct vpif_subdev_info *subdevdata;
	struct vpif_subdev_info *subdevdata;
	struct vpif_display_config *config;
	struct vpif_display_config *config;
	int i, j = 0, k, q, m, err = 0;
	int i, j = 0, k, err = 0;
	int res_idx = 0;
	struct i2c_adapter *i2c_adap;
	struct i2c_adapter *i2c_adap;
	struct common_obj *common;
	struct common_obj *common;
	struct channel_obj *ch;
	struct channel_obj *ch;
@@ -1630,21 +1631,22 @@ static __init int vpif_probe(struct platform_device *pdev)
		return err;
		return err;
	}
	}


	k = 0;
	while ((res = platform_get_resource(pdev, IORESOURCE_IRQ, res_idx))) {
	while ((res = platform_get_resource(pdev, IORESOURCE_IRQ, k))) {
		for (i = res->start; i <= res->end; i++) {
		for (i = res->start; i <= res->end; i++) {
			if (request_irq(i, vpif_channel_isr, IRQF_SHARED,
			if (request_irq(i, vpif_channel_isr, IRQF_SHARED,
					"VPIF_Display",
					"VPIF_Display", (void *)
				(void *)(&vpif_obj.dev[k]->channel_id))) {
					(&vpif_obj.dev[res_idx]->channel_id))) {
				err = -EBUSY;
				err = -EBUSY;
				for (j = 0; j < i; j++)
					free_irq(j, (void *)
					(&vpif_obj.dev[res_idx]->channel_id));
				goto vpif_int_err;
				goto vpif_int_err;
			}
			}
		}
		}
		k++;
		res_idx++;
	}
	}


	for (i = 0; i < VPIF_DISPLAY_MAX_DEVICES; i++) {
	for (i = 0; i < VPIF_DISPLAY_MAX_DEVICES; i++) {

		/* Get the pointer to the channel object */
		/* Get the pointer to the channel object */
		ch = vpif_obj.dev[i];
		ch = vpif_obj.dev[i];


@@ -1699,7 +1701,7 @@ static __init int vpif_probe(struct platform_device *pdev)
	if (vpif_obj.sd == NULL) {
	if (vpif_obj.sd == NULL) {
		vpif_err("unable to allocate memory for subdevice pointers\n");
		vpif_err("unable to allocate memory for subdevice pointers\n");
		err = -ENOMEM;
		err = -ENOMEM;
		goto vpif_int_err;
		goto vpif_sd_error;
	}
	}


	for (i = 0; i < subdev_count; i++) {
	for (i = 0; i < subdev_count; i++) {
@@ -1776,14 +1778,19 @@ static __init int vpif_probe(struct platform_device *pdev)
	}
	}
probe_subdev_out:
probe_subdev_out:
	kfree(vpif_obj.sd);
	kfree(vpif_obj.sd);
vpif_sd_error:
	for (i = 0; i < VPIF_DISPLAY_MAX_DEVICES; i++) {
		ch = vpif_obj.dev[i];
		/* Note: does nothing if ch->video_dev == NULL */
		video_device_release(ch->video_dev);
	}
vpif_int_err:
vpif_int_err:
	v4l2_device_unregister(&vpif_obj.v4l2_dev);
	v4l2_device_unregister(&vpif_obj.v4l2_dev);
	vpif_err("VPIF IRQ request failed\n");
	vpif_err("VPIF IRQ request failed\n");
	for (q = k; k >= 0; k--) {
	for (i = 0; i < res_idx; i++) {
		for (m = i; m >= res->start; m--)
		res = platform_get_resource(pdev, IORESOURCE_IRQ, i);
			free_irq(m, (void *)(&vpif_obj.dev[k]->channel_id));
		for (j = res->start; j <= res->end; j++)
		res = platform_get_resource(pdev, IORESOURCE_IRQ, k-1);
			free_irq(j, (void *)(&vpif_obj.dev[i]->channel_id));
		m = res->end;
	}
	}


	return err;
	return err;