Message ID | 20230110015538.201332-2-shinichiro.kawasaki@wdc.com |
---|---|
State | Superseded |
Headers | show |
Series | scsi: mpi3mr: fix issues found by KASAN | expand |
On Jan 10, 2023 / 12:27, kernel test robot wrote: > Hi Shin'ichiro, > > Thank you for the patch! Perhaps something to improve: > > [auto build test WARNING on jejb-scsi/for-next] > [also build test WARNING on mkp-scsi/for-next linus/master v6.2-rc3 next-20230109] > [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#_base_tree_information] > > url: https://github.com/intel-lab-lkp/linux/commits/Shin-ichiro-Kawasaki/scsi-mpi3mr-remove-unnecessary-memcpy/20230110-095717 > base: https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next > patch link: https://lore.kernel.org/r/20230110015538.201332-2-shinichiro.kawasaki%40wdc.com > patch subject: [PATCH v3 1/5] scsi: mpi3mr: remove unnecessary memcpy > config: ia64-allyesconfig > compiler: ia64-linux-gcc (GCC) 12.1.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/intel-lab-lkp/linux/commit/fad43146fb864da8124537dd3a548f9c638cddd6 > git remote add linux-review https://github.com/intel-lab-lkp/linux > git fetch --no-tags linux-review Shin-ichiro-Kawasaki/scsi-mpi3mr-remove-unnecessary-memcpy/20230110-095717 > git checkout fad43146fb864da8124537dd3a548f9c638cddd6 > # save the config file > mkdir build_dir && cp config build_dir/.config > COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=ia64 olddefconfig > COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=ia64 SHELL=/bin/bash drivers/scsi/mpi3mr/ > > If you fix the issue, kindly add following tag where applicable > | Reported-by: kernel test robot <lkp@intel.com> > > All warnings (new ones prefixed by >>): > > drivers/scsi/mpi3mr/mpi3mr_app.c: In function 'mpi3mr_get_all_tgt_info': > >> drivers/scsi/mpi3mr/mpi3mr_app.c:301:18: warning: variable 'min_entrylen' set but not used [-Wunused-but-set-variable] > 301 | uint32_t min_entrylen = 0, kern_entrylen = 0, usr_entrylen = 0; > | ^~~~~~~~~~~~ This patch removes the reference to min_entrylen, and the 3rd patch adds back the reference. So, this warning can be fixed by moving the 1st patch in the series after the 3rd patch. Will do so in v4.
diff --git a/drivers/scsi/mpi3mr/mpi3mr_app.c b/drivers/scsi/mpi3mr/mpi3mr_app.c index 9baac224b213..5bbfdff70570 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_app.c +++ b/drivers/scsi/mpi3mr/mpi3mr_app.c @@ -293,7 +293,6 @@ static long mpi3mr_bsg_pel_enable(struct mpi3mr_ioc *mrioc, static long mpi3mr_get_all_tgt_info(struct mpi3mr_ioc *mrioc, struct bsg_job *job) { - long rval = -EINVAL; u16 num_devices = 0, i = 0, size; unsigned long flags; struct mpi3mr_tgt_dev *tgtdev; @@ -304,7 +303,7 @@ static long mpi3mr_get_all_tgt_info(struct mpi3mr_ioc *mrioc, if (job->request_payload.payload_len < sizeof(u32)) { dprint_bsg_err(mrioc, "%s: invalid size argument\n", __func__); - return rval; + return -EINVAL; } spin_lock_irqsave(&mrioc->tgtdev_lock, flags); @@ -349,20 +348,12 @@ static long mpi3mr_get_all_tgt_info(struct mpi3mr_ioc *mrioc, usr_entrylen = (job->request_payload.payload_len - sizeof(u32)) / sizeof(*devmap_info); usr_entrylen *= sizeof(*devmap_info); min_entrylen = min(usr_entrylen, kern_entrylen); - if (min_entrylen && (!memcpy(&alltgt_info->dmi, devmap_info, min_entrylen))) { - dprint_bsg_err(mrioc, "%s:%d: device map info copy failed\n", - __func__, __LINE__); - rval = -EFAULT; - goto out; - } sg_copy_from_buffer(job->request_payload.sg_list, job->request_payload.sg_cnt, alltgt_info, job->request_payload.payload_len); - rval = 0; -out: kfree(alltgt_info); - return rval; + return 0; } /** * mpi3mr_get_change_count - Get topology change count
In the function mpi3mr_get_all_tgt_info, devmap_info points to alltgt_info->dmi then there is no need to memcpy data from devmap_info to alltgt_info->dmi. Remove the unnecessary memcpy. This also allows to remove the local variable 'rval' and the goto label 'out'. Fixes: f5e6d5a34376 ("scsi: mpi3mr: Add support for driver commands") Cc: stable@vger.kernel.org Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com> --- drivers/scsi/mpi3mr/mpi3mr_app.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-)