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

Commit 601b9ca8 authored by Ayaz Ahmad's avatar Ayaz Ahmad
Browse files

radio: iris: Avoid memory leak and NULL pointer dereferencing



 - Avoid memory leak by freeing allocated memory
 - Do not derefer NULL pointer

CRs-Fixed: 537955
Signed-off-by: default avatarAyaz Ahmad <aahmad@codeaurora.org>
Change-Id: I7624d73e5c25233e9d03c67e4204c611b9a8fff6
parent 06300feb
Loading
Loading
Loading
Loading
+14 −6
Original line number Diff line number Diff line
@@ -4275,13 +4275,13 @@ static int __init iris_probe(struct platform_device *pdev)
		if (kfifo_alloc_rc != 0) {
			FMDERR("failed allocating buffers %d\n",
				   kfifo_alloc_rc);
			for (; i > -1; i--) {
			for (; i > -1; i--)
				kfifo_free(&radio->data_buf[i]);
			video_device_release(radio->videodev);
			kfree(radio);
			return -ENOMEM;
		}
	}
	}

	mutex_init(&radio->lock);
	init_completion(&radio->sync_xfr_start);
@@ -4307,8 +4307,16 @@ static int __init iris_probe(struct platform_device *pdev)
	} else {
		priv_videodev = kzalloc(sizeof(struct video_device),
			GFP_KERNEL);
		if (priv_videodev != NULL) {
			memcpy(priv_videodev, radio->videodev,
				sizeof(struct video_device));
		} else {
			video_unregister_device(radio->videodev);
			video_device_release(radio->videodev);
			for (; i > -1; i--)
				kfifo_free(&radio->data_buf[i]);
			kfree(radio);
		}
	}
	return 0;
}