tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: 1b929c02afd37871d5afb9d498426f83432e71c2 commit: 73278d483378cf850ade923a1107a70297b2602a media: v4l2-ctrls-api.c: add back dropped ctrl->is_new = 1 config: sh-randconfig-m031-20221228 compiler: sh4-linux-gcc (GCC) 12.1.0 If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@xxxxxxxxx> | Reported-by: Dan Carpenter <error27@xxxxxxxxx> smatch warnings: drivers/media/v4l2-core/v4l2-ctrls-api.c:152 user_to_new() warn: if statement not indented drivers/media/v4l2-core/v4l2-ctrls-api.c:154 user_to_new() warn: inconsistent indenting vim +152 drivers/media/v4l2-core/v4l2-ctrls-api.c fb582cba44928f Hans Verkuil 2022-07-08 98 static int user_to_new(struct v4l2_ext_control *c, struct v4l2_ctrl *ctrl) 71c689dc2e732d Hans Verkuil 2021-04-27 99 { 71c689dc2e732d Hans Verkuil 2021-04-27 100 int ret; 71c689dc2e732d Hans Verkuil 2021-04-27 101 u32 size; 71c689dc2e732d Hans Verkuil 2021-04-27 102 fb582cba44928f Hans Verkuil 2022-07-08 103 ctrl->is_new = 0; fb582cba44928f Hans Verkuil 2022-07-08 104 if (ctrl->is_dyn_array && 5f2c5c69a61dc5 Hans Verkuil 2022-07-11 105 c->size > ctrl->p_array_alloc_elems * ctrl->elem_size) { 5f2c5c69a61dc5 Hans Verkuil 2022-07-11 106 void *old = ctrl->p_array; fb582cba44928f Hans Verkuil 2022-07-08 107 void *tmp = kvzalloc(2 * c->size, GFP_KERNEL); fb582cba44928f Hans Verkuil 2022-07-08 108 fb582cba44928f Hans Verkuil 2022-07-08 109 if (!tmp) fb582cba44928f Hans Verkuil 2022-07-08 110 return -ENOMEM; fb582cba44928f Hans Verkuil 2022-07-08 111 memcpy(tmp, ctrl->p_new.p, ctrl->elems * ctrl->elem_size); fb582cba44928f Hans Verkuil 2022-07-08 112 memcpy(tmp + c->size, ctrl->p_cur.p, ctrl->elems * ctrl->elem_size); fb582cba44928f Hans Verkuil 2022-07-08 113 ctrl->p_new.p = tmp; fb582cba44928f Hans Verkuil 2022-07-08 114 ctrl->p_cur.p = tmp + c->size; 5f2c5c69a61dc5 Hans Verkuil 2022-07-11 115 ctrl->p_array = tmp; 5f2c5c69a61dc5 Hans Verkuil 2022-07-11 116 ctrl->p_array_alloc_elems = c->size / ctrl->elem_size; fb582cba44928f Hans Verkuil 2022-07-08 117 kvfree(old); fb582cba44928f Hans Verkuil 2022-07-08 118 } fb582cba44928f Hans Verkuil 2022-07-08 119 71c689dc2e732d Hans Verkuil 2021-04-27 120 if (ctrl->is_ptr && !ctrl->is_string) { fb582cba44928f Hans Verkuil 2022-07-08 121 unsigned int elems = c->size / ctrl->elem_size; 71c689dc2e732d Hans Verkuil 2021-04-27 122 fb582cba44928f Hans Verkuil 2022-07-08 123 if (copy_from_user(ctrl->p_new.p, c->ptr, c->size)) fb582cba44928f Hans Verkuil 2022-07-08 124 return -EFAULT; fb582cba44928f Hans Verkuil 2022-07-08 125 ctrl->is_new = 1; fb582cba44928f Hans Verkuil 2022-07-08 126 if (ctrl->is_dyn_array) fb582cba44928f Hans Verkuil 2022-07-08 127 ctrl->new_elems = elems; fb582cba44928f Hans Verkuil 2022-07-08 128 else if (ctrl->is_array) cd75981ec93a3a Hans Verkuil 2022-08-29 129 ctrl->type_ops->init(ctrl, elems, ctrl->p_new); 71c689dc2e732d Hans Verkuil 2021-04-27 130 return 0; 71c689dc2e732d Hans Verkuil 2021-04-27 131 } 71c689dc2e732d Hans Verkuil 2021-04-27 132 71c689dc2e732d Hans Verkuil 2021-04-27 133 switch (ctrl->type) { 71c689dc2e732d Hans Verkuil 2021-04-27 134 case V4L2_CTRL_TYPE_INTEGER64: fb582cba44928f Hans Verkuil 2022-07-08 135 *ctrl->p_new.p_s64 = c->value64; 71c689dc2e732d Hans Verkuil 2021-04-27 136 break; 71c689dc2e732d Hans Verkuil 2021-04-27 137 case V4L2_CTRL_TYPE_STRING: 71c689dc2e732d Hans Verkuil 2021-04-27 138 size = c->size; 71c689dc2e732d Hans Verkuil 2021-04-27 139 if (size == 0) 71c689dc2e732d Hans Verkuil 2021-04-27 140 return -ERANGE; 71c689dc2e732d Hans Verkuil 2021-04-27 141 if (size > ctrl->maximum + 1) 71c689dc2e732d Hans Verkuil 2021-04-27 142 size = ctrl->maximum + 1; fb582cba44928f Hans Verkuil 2022-07-08 143 ret = copy_from_user(ctrl->p_new.p_char, c->string, size) ? -EFAULT : 0; 71c689dc2e732d Hans Verkuil 2021-04-27 144 if (!ret) { fb582cba44928f Hans Verkuil 2022-07-08 145 char last = ctrl->p_new.p_char[size - 1]; 71c689dc2e732d Hans Verkuil 2021-04-27 146 fb582cba44928f Hans Verkuil 2022-07-08 147 ctrl->p_new.p_char[size - 1] = 0; 71c689dc2e732d Hans Verkuil 2021-04-27 148 /* 71c689dc2e732d Hans Verkuil 2021-04-27 149 * If the string was longer than ctrl->maximum, 71c689dc2e732d Hans Verkuil 2021-04-27 150 * then return an error. 71c689dc2e732d Hans Verkuil 2021-04-27 151 */ fb582cba44928f Hans Verkuil 2022-07-08 @152 if (strlen(ctrl->p_new.p_char) == ctrl->maximum && last) 73278d483378cf Hans Verkuil 2022-12-12 153 ctrl->is_new = 1; Was "ctrl->is_new = 1;" supposed to go before the if statement? 71c689dc2e732d Hans Verkuil 2021-04-27 @154 return -ERANGE; 71c689dc2e732d Hans Verkuil 2021-04-27 155 } 71c689dc2e732d Hans Verkuil 2021-04-27 156 return ret; 71c689dc2e732d Hans Verkuil 2021-04-27 157 default: fb582cba44928f Hans Verkuil 2022-07-08 158 *ctrl->p_new.p_s32 = c->value; 71c689dc2e732d Hans Verkuil 2021-04-27 159 break; 71c689dc2e732d Hans Verkuil 2021-04-27 160 } fb582cba44928f Hans Verkuil 2022-07-08 161 ctrl->is_new = 1; 71c689dc2e732d Hans Verkuil 2021-04-27 162 return 0; 71c689dc2e732d Hans Verkuil 2021-04-27 163 } -- 0-DAY CI Kernel Test Service https://01.org/lkp