drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c:106 dpu_rm_init() warn: passing zero to 'PTR_ERR'
From: Dan Carpenter
Date: Tue Feb 09 2021 - 03:39:36 EST
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 61556703b610a104de324e4f061dc6cf7b218b46
commit: bb00a452d6f77391441ef7df48f7115dd459cd2f drm/msm/dpu: Refactor resource manager
config: arm64-randconfig-m031-20210209 (attached as .config)
compiler: aarch64-linux-gcc (GCC) 9.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
New smatch warnings:
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c:106 dpu_rm_init() warn: passing zero to 'PTR_ERR'
Old smatch warnings:
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c:135 dpu_rm_init() warn: passing zero to 'PTR_ERR'
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c:157 dpu_rm_init() warn: passing zero to 'PTR_ERR'
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c:174 dpu_rm_init() warn: passing zero to 'PTR_ERR'
vim +/PTR_ERR +106 drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 74 int dpu_rm_init(struct dpu_rm *rm,
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 75 struct dpu_mdss_cfg *cat,
3763f1a5511005 Jeykumar Sankaran 2018-12-07 76 void __iomem *mmio)
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 77 {
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 78 int rc, i;
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 79
3763f1a5511005 Jeykumar Sankaran 2018-12-07 80 if (!rm || !cat || !mmio) {
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 81 DPU_ERROR("invalid kms\n");
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 82 return -EINVAL;
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 83 }
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 84
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 85 /* Clear, setup lists */
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 86 memset(rm, 0, sizeof(*rm));
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 87
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 88 mutex_init(&rm->rm_lock);
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 89
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 90 /* Interrogate HW catalog and create tracking items for hw blocks */
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 91 for (i = 0; i < cat->mixer_count; i++) {
bb00a452d6f773 Drew Davenport 2020-02-19 92 struct dpu_hw_mixer *hw;
abda0d925f9c06 Stephen Boyd 2019-11-19 93 const struct dpu_lm_cfg *lm = &cat->mixer[i];
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 94
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 95 if (lm->pingpong == PINGPONG_MAX) {
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 96 DPU_DEBUG("skip mixer %d without pingpong\n", lm->id);
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 97 continue;
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 98 }
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 99
bb00a452d6f773 Drew Davenport 2020-02-19 100 if (lm->id < LM_0 || lm->id >= LM_MAX) {
bb00a452d6f773 Drew Davenport 2020-02-19 101 DPU_ERROR("skip mixer %d with invalid id\n", lm->id);
bb00a452d6f773 Drew Davenport 2020-02-19 102 continue;
bb00a452d6f773 Drew Davenport 2020-02-19 103 }
bb00a452d6f773 Drew Davenport 2020-02-19 104 hw = dpu_hw_lm_init(lm->id, mmio, cat);
bb00a452d6f773 Drew Davenport 2020-02-19 105 if (IS_ERR_OR_NULL(hw)) {
bb00a452d6f773 Drew Davenport 2020-02-19 @106 rc = PTR_ERR(hw);
bb00a452d6f773 Drew Davenport 2020-02-19 107 DPU_ERROR("failed lm object creation: err %d\n", rc);
The IS_ERR_OR_NULL() function is not a Ultra Strong version of IS_ERR().
When a function returns both error pointers and NULL then the NULL
pointer means the feature is optional and has been deliberately disabled.
It should not generate a warning. The driver should continue operating
without the optional feature (blinking lights or whatever).
PTR_ERR(NULL) is success/zero. Of course, the error handling checks for
success and changes that to -EFAULT. But it's hard to imagine that
-EFAULT is the correct error code either.
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 108 goto fail;
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 109 }
bb00a452d6f773 Drew Davenport 2020-02-19 110 rm->mixer_blks[lm->id - LM_0] = &hw->base;
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 111
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 112 if (!rm->lm_max_width) {
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 113 rm->lm_max_width = lm->sblk->maxwidth;
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 114 } else if (rm->lm_max_width != lm->sblk->maxwidth) {
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 115 /*
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 116 * Don't expect to have hw where lm max widths differ.
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 117 * If found, take the min.
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 118 */
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 119 DPU_ERROR("unsupported: lm maxwidth differs\n");
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 120 if (rm->lm_max_width > lm->sblk->maxwidth)
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 121 rm->lm_max_width = lm->sblk->maxwidth;
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 122 }
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 123 }
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 124
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 125 for (i = 0; i < cat->pingpong_count; i++) {
bb00a452d6f773 Drew Davenport 2020-02-19 126 struct dpu_hw_pingpong *hw;
bb00a452d6f773 Drew Davenport 2020-02-19 127 const struct dpu_pingpong_cfg *pp = &cat->pingpong[i];
bb00a452d6f773 Drew Davenport 2020-02-19 128
bb00a452d6f773 Drew Davenport 2020-02-19 129 if (pp->id < PINGPONG_0 || pp->id >= PINGPONG_MAX) {
bb00a452d6f773 Drew Davenport 2020-02-19 130 DPU_ERROR("skip pingpong %d with invalid id\n", pp->id);
bb00a452d6f773 Drew Davenport 2020-02-19 131 continue;
bb00a452d6f773 Drew Davenport 2020-02-19 132 }
bb00a452d6f773 Drew Davenport 2020-02-19 133 hw = dpu_hw_pingpong_init(pp->id, mmio, cat);
bb00a452d6f773 Drew Davenport 2020-02-19 134 if (IS_ERR_OR_NULL(hw)) {
bb00a452d6f773 Drew Davenport 2020-02-19 135 rc = PTR_ERR(hw);
bb00a452d6f773 Drew Davenport 2020-02-19 136 DPU_ERROR("failed pingpong object creation: err %d\n",
bb00a452d6f773 Drew Davenport 2020-02-19 137 rc);
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 138 goto fail;
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 139 }
bb00a452d6f773 Drew Davenport 2020-02-19 140 rm->pingpong_blks[pp->id - PINGPONG_0] = &hw->base;
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 141 }
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 142
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 143 for (i = 0; i < cat->intf_count; i++) {
bb00a452d6f773 Drew Davenport 2020-02-19 144 struct dpu_hw_intf *hw;
bb00a452d6f773 Drew Davenport 2020-02-19 145 const struct dpu_intf_cfg *intf = &cat->intf[i];
bb00a452d6f773 Drew Davenport 2020-02-19 146
bb00a452d6f773 Drew Davenport 2020-02-19 147 if (intf->type == INTF_NONE) {
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 148 DPU_DEBUG("skip intf %d with type none\n", i);
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 149 continue;
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 150 }
bb00a452d6f773 Drew Davenport 2020-02-19 151 if (intf->id < INTF_0 || intf->id >= INTF_MAX) {
bb00a452d6f773 Drew Davenport 2020-02-19 152 DPU_ERROR("skip intf %d with invalid id\n", intf->id);
bb00a452d6f773 Drew Davenport 2020-02-19 153 continue;
bb00a452d6f773 Drew Davenport 2020-02-19 154 }
bb00a452d6f773 Drew Davenport 2020-02-19 155 hw = dpu_hw_intf_init(intf->id, mmio, cat);
bb00a452d6f773 Drew Davenport 2020-02-19 156 if (IS_ERR_OR_NULL(hw)) {
bb00a452d6f773 Drew Davenport 2020-02-19 157 rc = PTR_ERR(hw);
bb00a452d6f773 Drew Davenport 2020-02-19 158 DPU_ERROR("failed intf object creation: err %d\n", rc);
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 159 goto fail;
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 160 }
bb00a452d6f773 Drew Davenport 2020-02-19 161 rm->intf_blks[intf->id - INTF_0] = &hw->base;
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 162 }
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 163
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 164 for (i = 0; i < cat->ctl_count; i++) {
bb00a452d6f773 Drew Davenport 2020-02-19 165 struct dpu_hw_ctl *hw;
bb00a452d6f773 Drew Davenport 2020-02-19 166 const struct dpu_ctl_cfg *ctl = &cat->ctl[i];
bb00a452d6f773 Drew Davenport 2020-02-19 167
bb00a452d6f773 Drew Davenport 2020-02-19 168 if (ctl->id < CTL_0 || ctl->id >= CTL_MAX) {
bb00a452d6f773 Drew Davenport 2020-02-19 169 DPU_ERROR("skip ctl %d with invalid id\n", ctl->id);
bb00a452d6f773 Drew Davenport 2020-02-19 170 continue;
bb00a452d6f773 Drew Davenport 2020-02-19 171 }
bb00a452d6f773 Drew Davenport 2020-02-19 172 hw = dpu_hw_ctl_init(ctl->id, mmio, cat);
bb00a452d6f773 Drew Davenport 2020-02-19 173 if (IS_ERR_OR_NULL(hw)) {
bb00a452d6f773 Drew Davenport 2020-02-19 174 rc = PTR_ERR(hw);
bb00a452d6f773 Drew Davenport 2020-02-19 175 DPU_ERROR("failed ctl object creation: err %d\n", rc);
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 176 goto fail;
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 177 }
bb00a452d6f773 Drew Davenport 2020-02-19 178 rm->ctl_blks[ctl->id - CTL_0] = &hw->base;
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 179 }
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 180
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 181 return 0;
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 182
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 183 fail:
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 184 dpu_rm_destroy(rm);
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 185
bb00a452d6f773 Drew Davenport 2020-02-19 186 return rc ? rc : -EFAULT;
25fdd5933e4c0f Jeykumar Sankaran 2018-06-27 187 }
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx
Attachment:
.config.gz
Description: application/gzip