From: Kiwoong Kim Date: Mon, 26 Jun 2017 13:10:55 +0000 (+0900) Subject: [COMMON] scsi: ufs: Fix a potential bug for using a single ton pointer X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=75b1c70ca826c7d8e9ab5d62294c6d4efc06ec0a;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git [COMMON] scsi: ufs: Fix a potential bug for using a single ton pointer find_last_bit function is supposed to receive an array pointer as the first argument. Of course I don't think most UFS host controllers have more than 64 slots. If some controllers have more than 64 slosts, another expression around here using lrb_in_use should be modified. Change-Id: Ie8960dae813ce7843ea868433d17fbe821bbe5cd Signed-off-by: Kiwoong Kim --- diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index c342a6635c3d..ad1e51a176fc 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -2716,7 +2716,8 @@ static bool ufshcd_get_dev_cmd_tag(struct ufs_hba *hba, int *tag_out) do { tmp = ~hba->lrb_in_use; - tag = find_last_bit(&tmp, hba->nutrs); + tmp &= BITMAP_LAST_WORD_MASK(hba->nutrs); + tag = (tmp) ? __fls(tmp) : ~0ul; if (tag >= hba->nutrs) goto out; } while (test_and_set_bit_lock(tag, &hba->lrb_in_use));