Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1379304

Re: [PATCH] media: saa7134 fix media_dev alloc error path to not free when alloc fails

From Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Newsgroups linux.kernel
Subject Re: [PATCH] media: saa7134 fix media_dev alloc error path to not free when alloc fails
Date 2016-04-14 23:10 +0200
Message-ID <rnWGu-5f-13@gated-at.bofh.it> (permalink)
References <rnStc-4TB-21@gated-at.bofh.it>
Organization Samsung

Show all headers | View raw


Em Thu, 14 Apr 2016 10:31:20 -0600
Shuah Khan <shuahkh@osg.samsung.com> escreveu:

> media_dev alloc error path does kfree when alloc fails. Fix it to not call
> kfree when media_dev alloc fails.

No need. kfree(NULL) is OK.

Adding a label inside a conditional block is ugly.

> 

> Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
> ---
>  drivers/media/pci/saa7134/saa7134-core.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/pci/saa7134/saa7134-core.c b/drivers/media/pci/saa7134/saa7134-core.c
> index c0e1780..eab2684 100644
> --- a/drivers/media/pci/saa7134/saa7134-core.c
> +++ b/drivers/media/pci/saa7134/saa7134-core.c
> @@ -1046,7 +1046,7 @@ static int saa7134_initdev(struct pci_dev *pci_dev,
>  	dev->media_dev = kzalloc(sizeof(*dev->media_dev), GFP_KERNEL);
>  	if (!dev->media_dev) {
>  		err = -ENOMEM;
> -		goto fail0;
> +		goto media_dev_alloc_fail;
>  	}
>  	media_device_pci_init(dev->media_dev, pci_dev, dev->name);
>  	dev->v4l2_dev.mdev = dev->media_dev;
> @@ -1309,6 +1309,7 @@ static int saa7134_initdev(struct pci_dev *pci_dev,
>   fail0:
>  #ifdef CONFIG_MEDIA_CONTROLLER
>  	kfree(dev->media_dev);
> + media_dev_alloc_fail:
>  #endif
>  	kfree(dev);
>  	return err;


-- 
Thanks,
Mauro

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] media: saa7134 fix media_dev alloc error path to not free when alloc fails Shuah Khan <shuahkh@osg.samsung.com> - 2016-04-14 18:40 +0200
  Re: [PATCH] media: saa7134 fix media_dev alloc error path to not  free when alloc fails Mauro Carvalho Chehab <mchehab@osg.samsung.com> - 2016-04-14 23:10 +0200
    Re: [PATCH] media: saa7134 fix media_dev alloc error path to not free  when alloc fails Shuah Khan <shuah.kh@samsung.com> - 2016-04-15 00:20 +0200
      Re: [PATCH] media: saa7134 fix media_dev alloc error path to not  free when alloc fails Mauro Carvalho Chehab <mchehab@osg.samsung.com> - 2016-04-15 11:50 +0200

csiph-web