linux-fpga.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fpga: dfl: add missing platform_device_put in build_info_create_dev
@ 2020-11-25  6:50 Qinglang Miao
  2020-11-25  9:22 ` kernel test robot
  2020-11-25 10:06 ` Wu, Hao
  0 siblings, 2 replies; 4+ messages in thread
From: Qinglang Miao @ 2020-11-25  6:50 UTC (permalink / raw)
  To: Wu Hao, Tom Rix, Moritz Fischer; +Cc: linux-fpga, linux-kernel, Qinglang Miao

platform_device_put is missing when it fails to set fdev->id. Set
a temp value to do sanity check.

Fixes: 543be3d8c999 ("fpga: add device feature list support")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Qinglang Miao <miaoqinglang@huawei.com>
---
 drivers/fpga/dfl.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/fpga/dfl.c b/drivers/fpga/dfl.c
index b450870b7..8958f0860 100644
--- a/drivers/fpga/dfl.c
+++ b/drivers/fpga/dfl.c
@@ -877,10 +877,13 @@ build_info_create_dev(struct build_feature_devs_info *binfo,
 
 	INIT_LIST_HEAD(&binfo->sub_features);
 
-	fdev->id = dfl_id_alloc(type, &fdev->dev);
-	if (fdev->id < 0)
-		return fdev->id;
+	int tmp_id = dfl_id_alloc(type, &fdev->dev);
+	if (tmp_id < 0) {
+		platform_device_put(fdev);
+		return tmp_id;
+	}
 
+	fdev->id = tmp_id;
 	fdev->dev.parent = &binfo->cdev->region->dev;
 	fdev->dev.devt = dfl_get_devt(dfl_devs[type].devt_type, fdev->id);
 
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] fpga: dfl: add missing platform_device_put in build_info_create_dev
  2020-11-25  6:50 [PATCH] fpga: dfl: add missing platform_device_put in build_info_create_dev Qinglang Miao
@ 2020-11-25  9:22 ` kernel test robot
  2020-11-25 10:06 ` Wu, Hao
  1 sibling, 0 replies; 4+ messages in thread
From: kernel test robot @ 2020-11-25  9:22 UTC (permalink / raw)
  To: Qinglang Miao, Wu Hao, Tom Rix, Moritz Fischer
  Cc: kbuild-all, linux-fpga, linux-kernel, Qinglang Miao

[-- Attachment #1: Type: text/plain, Size: 2919 bytes --]

Hi Qinglang,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v5.10-rc5 next-20201124]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Qinglang-Miao/fpga-dfl-add-missing-platform_device_put-in-build_info_create_dev/20201125-145159
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 127c501a03d5db8b833e953728d3bcf53c8832a9
config: arc-randconfig-m031-20201125 (attached as .config)
compiler: arc-elf-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/86dbfca89da921d0c3c9682ea35cdb3b2e40e6be
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Qinglang-Miao/fpga-dfl-add-missing-platform_device_put-in-build_info_create_dev/20201125-145159
        git checkout 86dbfca89da921d0c3c9682ea35cdb3b2e40e6be
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arc 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   drivers/fpga/dfl.c: In function 'build_info_create_dev':
>> drivers/fpga/dfl.c:880:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
     880 |  int tmp_id = dfl_id_alloc(type, &fdev->dev);
         |  ^~~

vim +880 drivers/fpga/dfl.c

   857	
   858	static int
   859	build_info_create_dev(struct build_feature_devs_info *binfo,
   860			      enum dfl_id_type type)
   861	{
   862		struct platform_device *fdev;
   863	
   864		if (type >= DFL_ID_MAX)
   865			return -EINVAL;
   866	
   867		/*
   868		 * we use -ENODEV as the initialization indicator which indicates
   869		 * whether the id need to be reclaimed
   870		 */
   871		fdev = platform_device_alloc(dfl_devs[type].name, -ENODEV);
   872		if (!fdev)
   873			return -ENOMEM;
   874	
   875		binfo->feature_dev = fdev;
   876		binfo->feature_num = 0;
   877	
   878		INIT_LIST_HEAD(&binfo->sub_features);
   879	
 > 880		int tmp_id = dfl_id_alloc(type, &fdev->dev);
   881		if (tmp_id < 0) {
   882			platform_device_put(fdev);
   883			return tmp_id;
   884		}
   885	
   886		fdev->id = tmp_id;
   887		fdev->dev.parent = &binfo->cdev->region->dev;
   888		fdev->dev.devt = dfl_get_devt(dfl_devs[type].devt_type, fdev->id);
   889	
   890		return 0;
   891	}
   892	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 22212 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH] fpga: dfl: add missing platform_device_put in build_info_create_dev
  2020-11-25  6:50 [PATCH] fpga: dfl: add missing platform_device_put in build_info_create_dev Qinglang Miao
  2020-11-25  9:22 ` kernel test robot
@ 2020-11-25 10:06 ` Wu, Hao
  2020-11-26  1:17   ` Qinglang Miao
  1 sibling, 1 reply; 4+ messages in thread
From: Wu, Hao @ 2020-11-25 10:06 UTC (permalink / raw)
  To: Qinglang Miao, Tom Rix, Moritz Fischer; +Cc: linux-fpga, linux-kernel

> Subject: [PATCH] fpga: dfl: add missing platform_device_put in
> build_info_create_dev
> 
> platform_device_put is missing when it fails to set fdev->id. Set
> a temp value to do sanity check.

will this case be covered already by build_info_free()?

Hao

> 
> Fixes: 543be3d8c999 ("fpga: add device feature list support")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Qinglang Miao <miaoqinglang@huawei.com>
> ---
>  drivers/fpga/dfl.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/fpga/dfl.c b/drivers/fpga/dfl.c
> index b450870b7..8958f0860 100644
> --- a/drivers/fpga/dfl.c
> +++ b/drivers/fpga/dfl.c
> @@ -877,10 +877,13 @@ build_info_create_dev(struct
> build_feature_devs_info *binfo,
> 
>  	INIT_LIST_HEAD(&binfo->sub_features);
> 
> -	fdev->id = dfl_id_alloc(type, &fdev->dev);
> -	if (fdev->id < 0)
> -		return fdev->id;
> +	int tmp_id = dfl_id_alloc(type, &fdev->dev);
> +	if (tmp_id < 0) {
> +		platform_device_put(fdev);
> +		return tmp_id;
> +	}
> 
> +	fdev->id = tmp_id;
>  	fdev->dev.parent = &binfo->cdev->region->dev;
>  	fdev->dev.devt = dfl_get_devt(dfl_devs[type].devt_type, fdev->id);
> 
> --
> 2.23.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] fpga: dfl: add missing platform_device_put in build_info_create_dev
  2020-11-25 10:06 ` Wu, Hao
@ 2020-11-26  1:17   ` Qinglang Miao
  0 siblings, 0 replies; 4+ messages in thread
From: Qinglang Miao @ 2020-11-26  1:17 UTC (permalink / raw)
  To: Wu, Hao, Tom Rix, Moritz Fischer; +Cc: linux-fpga, linux-kernel



在 2020/11/25 18:06, Wu, Hao 写道:
>> Subject: [PATCH] fpga: dfl: add missing platform_device_put in
>> build_info_create_dev
>>
>> platform_device_put is missing when it fails to set fdev->id. Set
>> a temp value to do sanity check.
> 
> will this case be covered already by build_info_free()?
> 
> Hao
Yes, you're right Hao.

build_info_create_dev is performed in parse_feature_list which follows
build_info_free.

So please ignore this patch.

Thanks!
> 
>>
>> Fixes: 543be3d8c999 ("fpga: add device feature list support")
>> Reported-by: Hulk Robot <hulkci@huawei.com>
>> Signed-off-by: Qinglang Miao <miaoqinglang@huawei.com>
>> ---
>>   drivers/fpga/dfl.c | 9 ++++++---
>>   1 file changed, 6 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/fpga/dfl.c b/drivers/fpga/dfl.c
>> index b450870b7..8958f0860 100644
>> --- a/drivers/fpga/dfl.c
>> +++ b/drivers/fpga/dfl.c
>> @@ -877,10 +877,13 @@ build_info_create_dev(struct
>> build_feature_devs_info *binfo,
>>
>>   	INIT_LIST_HEAD(&binfo->sub_features);
>>
>> -	fdev->id = dfl_id_alloc(type, &fdev->dev);
>> -	if (fdev->id < 0)
>> -		return fdev->id;
>> +	int tmp_id = dfl_id_alloc(type, &fdev->dev);
>> +	if (tmp_id < 0) {
>> +		platform_device_put(fdev);
>> +		return tmp_id;
>> +	}
>>
>> +	fdev->id = tmp_id;
>>   	fdev->dev.parent = &binfo->cdev->region->dev;
>>   	fdev->dev.devt = dfl_get_devt(dfl_devs[type].devt_type, fdev->id);
>>
>> --
>> 2.23.0
> 
> .
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-11-26  1:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-25  6:50 [PATCH] fpga: dfl: add missing platform_device_put in build_info_create_dev Qinglang Miao
2020-11-25  9:22 ` kernel test robot
2020-11-25 10:06 ` Wu, Hao
2020-11-26  1:17   ` Qinglang Miao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).