[COMMON] scsi: ufs: Fix a potential bug for using a single ton pointer
authorKiwoong Kim <kwmad.kim@samsung.com>
Mon, 26 Jun 2017 13:10:55 +0000 (22:10 +0900)
committerJaeHun Jung <jh0801.jung@samsung.com>
Tue, 8 May 2018 08:21:47 +0000 (17:21 +0900)
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 <kwmad.kim@samsung.com>
drivers/scsi/ufs/ufshcd.c

index c342a6635c3ddb902326a71cea51806f5b0c5a3f..ad1e51a176fc3b266836937f879388ce95e9b689 100644 (file)
@@ -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));