tree: https://gitee.com/openeuler/kernel.git openEuler-1.0-LTS head: 4f763890ac28e4d36527b22a830c5e95cae55470 commit: 325d9be9a6518184aec9fdbd87f11759b1e32a56 [1312/1312] tty: fix possible deadlock in console_unlock config: arm64-randconfig-002-20241127 (https://download.01.org/0day-ci/archive/20241128/202411280023.3EwZG5dg-lkp@i...) compiler: aarch64-linux-gcc (GCC) 14.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241128/202411280023.3EwZG5dg-lkp@i...)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot lkp@intel.com | Closes: https://lore.kernel.org/oe-kbuild-all/202411280023.3EwZG5dg-lkp@intel.com/
All errors (new ones prefixed by >>):
drivers/tty/tty_buffer.c: In function 'tty_buffer_alloc':
drivers/tty/tty_buffer.c:170:9: error: implicit declaration of function 'printk_safe_enter'; did you mean 'printk_safe_init'? [-Werror=implicit-function-declaration]
170 | printk_safe_enter(); | ^~~~~~~~~~~~~~~~~ | printk_safe_init drivers/tty/tty_buffer.c:172:9: error: implicit declaration of function 'printk_safe_exit'; did you mean 'printk_safe_init'? [-Werror=implicit-function-declaration] 172 | printk_safe_exit(); | ^~~~~~~~~~~~~~~~ | printk_safe_init drivers/tty/tty_buffer.c: In function '__tty_insert_flip_char': drivers/tty/tty_buffer.c:386:45: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] 386 | *flag_buf_ptr(tb, tb->used) = flag; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~ In file included from drivers/tty/tty_buffer.c:8: include/linux/tty.h:69:23: note: destination object 'data' of size 0 69 | unsigned long data[0]; | ^~~~ drivers/tty/tty_buffer.c:387:39: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] 387 | *char_buf_ptr(tb, tb->used++) = ch; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~ include/linux/tty.h:69:23: note: destination object 'data' of size 0 69 | unsigned long data[0]; | ^~~~ cc1: some warnings being treated as errors
vim +170 drivers/tty/tty_buffer.c
137 138 /** 139 * tty_buffer_alloc - allocate a tty buffer 140 * @tty: tty device 141 * @size: desired size (characters) 142 * 143 * Allocate a new tty buffer to hold the desired number of characters. 144 * We round our buffers off in 256 character chunks to get better 145 * allocation behaviour. 146 * Return NULL if out of memory or the allocation would exceed the 147 * per device queue 148 */ 149 150 static struct tty_buffer *tty_buffer_alloc(struct tty_port *port, size_t size) 151 { 152 struct llist_node *free; 153 struct tty_buffer *p; 154 155 /* Round the buffer size out */ 156 size = __ALIGN_MASK(size, TTYB_ALIGN_MASK); 157 158 if (size <= MIN_TTYB_SIZE) { 159 free = llist_del_first(&port->buf.free); 160 if (free) { 161 p = llist_entry(free, struct tty_buffer, free); 162 goto found; 163 } 164 } 165 166 /* Should possibly check if this fails for the largest buffer we 167 have queued and recycle that ? */ 168 if (atomic_read(&port->buf.mem_used) > port->buf.mem_limit) 169 return NULL;
170 printk_safe_enter();
171 p = kmalloc(sizeof(struct tty_buffer) + 2 * size, GFP_ATOMIC); 172 printk_safe_exit(); 173 if (p == NULL) 174 return NULL; 175 176 found: 177 tty_buffer_reset(p, size); 178 atomic_add(size, &port->buf.mem_used); 179 return p; 180 } 181