Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usbip: vudc: Don't enable IRQs prematurely

This code does:

spin_unlock_irq(&udc->ud.lock);
spin_unlock_irqrestore(&udc->lock, flags);

which does not make sense. In theory, the first unlock could enable
IRQs and then the second _irqrestore could disable them again. There
would be a brief momemt where IRQs were enabled improperly.

In real life, however, this function is always called with IRQs enabled
and the bug does not affect runtime.

Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/Yo4hVWcZNYzKEkIQ@kili
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Dan Carpenter and committed by
Greg Kroah-Hartman
62e4efe3 ecf6dedd

+7 -7
+7 -7
drivers/usb/usbip/vudc_sysfs.c
··· 128 128 goto unlock; 129 129 } 130 130 131 - spin_lock_irq(&udc->ud.lock); 131 + spin_lock(&udc->ud.lock); 132 132 133 133 if (udc->ud.status != SDEV_ST_AVAILABLE) { 134 134 ret = -EINVAL; ··· 150 150 } 151 151 152 152 /* unlock and create threads and get tasks */ 153 - spin_unlock_irq(&udc->ud.lock); 153 + spin_unlock(&udc->ud.lock); 154 154 spin_unlock_irqrestore(&udc->lock, flags); 155 155 156 156 tcp_rx = kthread_create(&v_rx_loop, &udc->ud, "vudc_rx"); ··· 173 173 174 174 /* lock and update udc->ud state */ 175 175 spin_lock_irqsave(&udc->lock, flags); 176 - spin_lock_irq(&udc->ud.lock); 176 + spin_lock(&udc->ud.lock); 177 177 178 178 udc->ud.tcp_socket = socket; 179 179 udc->ud.tcp_rx = tcp_rx; 180 180 udc->ud.tcp_tx = tcp_tx; 181 181 udc->ud.status = SDEV_ST_USED; 182 182 183 - spin_unlock_irq(&udc->ud.lock); 183 + spin_unlock(&udc->ud.lock); 184 184 185 185 ktime_get_ts64(&udc->start_time); 186 186 v_start_timer(udc); ··· 201 201 goto unlock; 202 202 } 203 203 204 - spin_lock_irq(&udc->ud.lock); 204 + spin_lock(&udc->ud.lock); 205 205 if (udc->ud.status != SDEV_ST_USED) { 206 206 ret = -EINVAL; 207 207 goto unlock_ud; 208 208 } 209 - spin_unlock_irq(&udc->ud.lock); 209 + spin_unlock(&udc->ud.lock); 210 210 211 211 usbip_event_add(&udc->ud, VUDC_EVENT_DOWN); 212 212 } ··· 219 219 sock_err: 220 220 sockfd_put(socket); 221 221 unlock_ud: 222 - spin_unlock_irq(&udc->ud.lock); 222 + spin_unlock(&udc->ud.lock); 223 223 unlock: 224 224 spin_unlock_irqrestore(&udc->lock, flags); 225 225 mutex_unlock(&udc->ud.sysfs_lock);