Commit 4cf752f
scsi: ufs: core: Fix NULL pointer dereference in scsi_cmd_priv() calls
ufshcd_tag_to_cmd() may return NULL if no command is associated with the
given tag. However, several callers dereference the returned cmd pointer
via scsi_cmd_priv() without checking for NULL first, leading to a
potential NULL pointer dereference.
Fix this by adding NULL checks for cmd before calling scsi_cmd_priv()
and moving the lrbp initialization after the NULL check.
Signed-off-by: Chanwoo Lee <cw9316.lee@samsung.com>
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Link: https://patch.msgid.link/20260529010739.295391-1-cw9316.lee@samsung.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>1 parent c39a9a0 commit 4cf752f
2 files changed
Lines changed: 17 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
637 | 637 | | |
638 | 638 | | |
639 | 639 | | |
640 | | - | |
| 640 | + | |
641 | 641 | | |
642 | 642 | | |
643 | 643 | | |
| |||
647 | 647 | | |
648 | 648 | | |
649 | 649 | | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
650 | 655 | | |
651 | 656 | | |
652 | 657 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7903 | 7903 | | |
7904 | 7904 | | |
7905 | 7905 | | |
7906 | | - | |
| 7906 | + | |
7907 | 7907 | | |
| 7908 | + | |
| 7909 | + | |
| 7910 | + | |
| 7911 | + | |
7908 | 7912 | | |
7909 | 7913 | | |
7910 | 7914 | | |
| |||
7925 | 7929 | | |
7926 | 7930 | | |
7927 | 7931 | | |
7928 | | - | |
| 7932 | + | |
7929 | 7933 | | |
7930 | 7934 | | |
7931 | 7935 | | |
7932 | 7936 | | |
| 7937 | + | |
| 7938 | + | |
| 7939 | + | |
| 7940 | + | |
| 7941 | + | |
7933 | 7942 | | |
7934 | 7943 | | |
7935 | 7944 | | |
| |||
0 commit comments