[efi:urgent 12/12] drivers/firmware/efi/libstub/efi-stub-helper.c:513:6: warning: variable 'dp' is used uninitialized whenever 'if' condition is false

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



tree:   https://git.kernel.org/pub/scm/linux/kernel/git/efi/efi.git urgent
head:   86237b46f2b202331c07e4c6c2633ce3d3ba7f13
commit: 86237b46f2b202331c07e4c6c2633ce3d3ba7f13 [12/12] efi: libstub: Look for initrd LoadFile2 protocol on image handle
config: riscv-randconfig-r042-20230313 (https://download.01.org/0day-ci/archive/20230318/202303180324.XvQkFoRV-lkp@xxxxxxxxx/config)
compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project 67409911353323ca5edf2049ef0df54132fa1ca7)
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
        # install riscv cross compiling tool for clang build
        # apt-get install binutils-riscv64-linux-gnu
        # https://git.kernel.org/pub/scm/linux/kernel/git/efi/efi.git/commit/?id=86237b46f2b202331c07e4c6c2633ce3d3ba7f13
        git remote add efi https://git.kernel.org/pub/scm/linux/kernel/git/efi/efi.git
        git fetch --no-tags efi urgent
        git checkout 86237b46f2b202331c07e4c6c2633ce3d3ba7f13
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=riscv olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=riscv SHELL=/bin/bash drivers/firmware/efi/libstub/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Link: https://lore.kernel.org/oe-kbuild-all/202303180324.XvQkFoRV-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

>> drivers/firmware/efi/libstub/efi-stub-helper.c:513:6: warning: variable 'dp' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
           if (status != EFI_SUCCESS) {
               ^~~~~~~~~~~~~~~~~~~~~
   drivers/firmware/efi/libstub/efi-stub-helper.c:528:42: note: uninitialized use occurs here
           status = efi_call_proto(lf2, load_file, dp, false, &initrd->size, NULL);
                                                   ^~
   drivers/firmware/efi/libstub/efistub.h:59:38: note: expanded from macro 'efi_call_proto'
           efi_fn_call(__inst, func, __inst, ##__VA_ARGS__);       \
                                               ^~~~~~~~~~~
   drivers/firmware/efi/libstub/efistub.h:53:51: note: expanded from macro 'efi_fn_call'
   #define efi_fn_call(inst, func, ...)    (inst)->func(__VA_ARGS__)
                                                        ^~~~~~~~~~~
   drivers/firmware/efi/libstub/efi-stub-helper.c:513:2: note: remove the 'if' if its condition is always true
           if (status != EFI_SUCCESS) {
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/firmware/efi/libstub/efi-stub-helper.c:505:32: note: initialize the variable 'dp' to silence this warning
           efi_device_path_protocol_t *dp;
                                         ^
                                          = NULL
   1 warning generated.


vim +513 drivers/firmware/efi/libstub/efi-stub-helper.c

   483	
   484	/**
   485	 * efi_load_initrd_lf2() - load the initrd from the Linux initrd device path
   486	 * @image_handle: EFI handle of the loaded image
   487	 * @initrd:	  pointer of struct to store the address where the initrd was
   488	 *                loaded and the size of the loaded initrd
   489	 * @max:	  upper limit for the initrd memory allocation
   490	 *
   491	 * Return:
   492	 * * %EFI_SUCCESS if the initrd was loaded successfully, in which
   493	 *   case @load_addr and @load_size are assigned accordingly
   494	 * * %EFI_NOT_FOUND if no LoadFile2 protocol exists on the initrd device path
   495	 * * %EFI_OUT_OF_RESOURCES if memory allocation failed
   496	 * * %EFI_LOAD_ERROR in all other cases
   497	 */
   498	static
   499	efi_status_t efi_load_initrd_lf2(efi_handle_t image_handle,
   500					 struct linux_efi_initrd *initrd,
   501					 unsigned long max)
   502	{
   503		efi_guid_t lf2_proto_guid = EFI_LOAD_FILE2_PROTOCOL_GUID;
   504		efi_guid_t initrd_lf2_proto_guid = LINUX_EFI_INITRD_LF2_PROTOCOL_GUID;
   505		efi_device_path_protocol_t *dp;
   506		efi_load_file2_protocol_t *lf2;
   507		efi_handle_t handle;
   508		efi_status_t status;
   509	
   510		/* first look for a initrd loading protocol specific to this image */
   511		status = efi_bs_call(handle_protocol, image_handle, &initrd_lf2_proto_guid,
   512				     (void **)&lf2);
 > 513		if (status != EFI_SUCCESS) {
   514			/* look for the global singleton initrd loading protocol */
   515			dp = (efi_device_path_protocol_t *)&initrd_dev_path;
   516			status = efi_bs_call(locate_device_path, &lf2_proto_guid, &dp,
   517					     &handle);
   518			if (status != EFI_SUCCESS)
   519				return status;
   520	
   521			status = efi_bs_call(handle_protocol, handle, &lf2_proto_guid,
   522					     (void **)&lf2);
   523			if (status != EFI_SUCCESS)
   524				return status;
   525		}
   526	
   527		initrd->size = 0;
   528		status = efi_call_proto(lf2, load_file, dp, false, &initrd->size, NULL);
   529		if (status != EFI_BUFFER_TOO_SMALL)
   530			return EFI_LOAD_ERROR;
   531	
   532		status = efi_allocate_pages(initrd->size, &initrd->base, max);
   533		if (status != EFI_SUCCESS)
   534			return status;
   535	
   536		status = efi_call_proto(lf2, load_file, dp, false, &initrd->size,
   537					(void *)initrd->base);
   538		if (status != EFI_SUCCESS) {
   539			efi_free(initrd->size, initrd->base);
   540			return EFI_LOAD_ERROR;
   541		}
   542		return EFI_SUCCESS;
   543	}
   544	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux