Skip to content

Commit 807c5d9

Browse files
committed
Merge remote-tracking branch 'stable/linux-4.9.y' into rpi-4.9.y
2 parents f65b249 + 458ca52 commit 807c5d9

File tree

13 files changed

+73
-142
lines changed

13 files changed

+73
-142
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
VERSION = 4
22
PATCHLEVEL = 9
3-
SUBLEVEL = 46
3+
SUBLEVEL = 47
44
EXTRAVERSION =
55
NAME = Roaring Lionus
66

arch/arm/kvm/mmu.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -829,22 +829,22 @@ void stage2_unmap_vm(struct kvm *kvm)
829829
* Walks the level-1 page table pointed to by kvm->arch.pgd and frees all
830830
* underlying level-2 and level-3 tables before freeing the actual level-1 table
831831
* and setting the struct pointer to NULL.
832-
*
833-
* Note we don't need locking here as this is only called when the VM is
834-
* destroyed, which can only be done once.
835832
*/
836833
void kvm_free_stage2_pgd(struct kvm *kvm)
837834
{
838-
if (kvm->arch.pgd == NULL)
839-
return;
835+
void *pgd = NULL;
840836

841837
spin_lock(&kvm->mmu_lock);
842-
unmap_stage2_range(kvm, 0, KVM_PHYS_SIZE);
838+
if (kvm->arch.pgd) {
839+
unmap_stage2_range(kvm, 0, KVM_PHYS_SIZE);
840+
pgd = kvm->arch.pgd;
841+
kvm->arch.pgd = NULL;
842+
}
843843
spin_unlock(&kvm->mmu_lock);
844844

845845
/* Free the HW pgd, one page at a time */
846-
free_pages_exact(kvm->arch.pgd, S2_PGD_SIZE);
847-
kvm->arch.pgd = NULL;
846+
if (pgd)
847+
free_pages_exact(pgd, S2_PGD_SIZE);
848848
}
849849

850850
static pud_t *stage2_get_pud(struct kvm *kvm, struct kvm_mmu_memory_cache *cache,

arch/arm64/kernel/fpsimd.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,11 @@ void fpsimd_thread_switch(struct task_struct *next)
157157

158158
void fpsimd_flush_thread(void)
159159
{
160+
preempt_disable();
160161
memset(&current->thread.fpsimd_state, 0, sizeof(struct fpsimd_state));
161162
fpsimd_flush_task_state(current);
162163
set_thread_flag(TIF_FOREIGN_FPSTATE);
164+
preempt_enable();
163165
}
164166

165167
/*

arch/arm64/mm/fault.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,11 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
373373
* signal first. We do not need to release the mmap_sem because it
374374
* would already be released in __lock_page_or_retry in mm/filemap.c.
375375
*/
376-
if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current))
376+
if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current)) {
377+
if (!user_mode(regs))
378+
goto no_context;
377379
return 0;
380+
}
378381

379382
/*
380383
* Major/minor page fault accounting is only done on the initial

arch/x86/include/asm/io.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,13 +304,13 @@ static inline unsigned type in##bwl##_p(int port) \
304304
static inline void outs##bwl(int port, const void *addr, unsigned long count) \
305305
{ \
306306
asm volatile("rep; outs" #bwl \
307-
: "+S"(addr), "+c"(count) : "d"(port)); \
307+
: "+S"(addr), "+c"(count) : "d"(port) : "memory"); \
308308
} \
309309
\
310310
static inline void ins##bwl(int port, void *addr, unsigned long count) \
311311
{ \
312312
asm volatile("rep; ins" #bwl \
313-
: "+D"(addr), "+c"(count) : "d"(port)); \
313+
: "+D"(addr), "+c"(count) : "d"(port) : "memory"); \
314314
}
315315

316316
BUILDIO(b, b, char)

drivers/net/wireless/intersil/p54/fwio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ int p54_scan(struct p54_common *priv, u16 mode, u16 dwell)
488488

489489
entry += sizeof(__le16);
490490
chan->pa_points_per_curve = 8;
491-
memset(chan->curve_data, 0, sizeof(*chan->curve_data));
491+
memset(chan->curve_data, 0, sizeof(chan->curve_data));
492492
memcpy(chan->curve_data, entry,
493493
sizeof(struct p54_pa_curve_data_sample) *
494494
min((u8)8, curve_data->points_per_channel));

drivers/scsi/isci/remote_node_context.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ const char *rnc_state_name(enum scis_sds_remote_node_context_states state)
6666
{
6767
static const char * const strings[] = RNC_STATES;
6868

69+
if (state >= ARRAY_SIZE(strings))
70+
return "UNKNOWN";
71+
6972
return strings[state];
7073
}
7174
#undef C

drivers/scsi/sg.c

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ typedef struct sg_fd { /* holds the state of a file descriptor */
142142
struct sg_device *parentdp; /* owning device */
143143
wait_queue_head_t read_wait; /* queue read until command done */
144144
rwlock_t rq_list_lock; /* protect access to list in req_arr */
145+
struct mutex f_mutex; /* protect against changes in this fd */
145146
int timeout; /* defaults to SG_DEFAULT_TIMEOUT */
146147
int timeout_user; /* defaults to SG_DEFAULT_TIMEOUT_USER */
147148
Sg_scatter_hold reserve; /* buffer held for this file descriptor */
@@ -155,6 +156,7 @@ typedef struct sg_fd { /* holds the state of a file descriptor */
155156
unsigned char next_cmd_len; /* 0: automatic, >0: use on next write() */
156157
char keep_orphan; /* 0 -> drop orphan (def), 1 -> keep for read() */
157158
char mmap_called; /* 0 -> mmap() never called on this fd */
159+
char res_in_use; /* 1 -> 'reserve' array in use */
158160
struct kref f_ref;
159161
struct execute_work ew;
160162
} Sg_fd;
@@ -198,7 +200,6 @@ static void sg_remove_sfp(struct kref *);
198200
static Sg_request *sg_get_rq_mark(Sg_fd * sfp, int pack_id);
199201
static Sg_request *sg_add_request(Sg_fd * sfp);
200202
static int sg_remove_request(Sg_fd * sfp, Sg_request * srp);
201-
static int sg_res_in_use(Sg_fd * sfp);
202203
static Sg_device *sg_get_dev(int dev);
203204
static void sg_device_destroy(struct kref *kref);
204205

@@ -614,6 +615,7 @@ sg_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos)
614615
}
615616
buf += SZ_SG_HEADER;
616617
__get_user(opcode, buf);
618+
mutex_lock(&sfp->f_mutex);
617619
if (sfp->next_cmd_len > 0) {
618620
cmd_size = sfp->next_cmd_len;
619621
sfp->next_cmd_len = 0; /* reset so only this write() effected */
@@ -622,6 +624,7 @@ sg_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos)
622624
if ((opcode >= 0xc0) && old_hdr.twelve_byte)
623625
cmd_size = 12;
624626
}
627+
mutex_unlock(&sfp->f_mutex);
625628
SCSI_LOG_TIMEOUT(4, sg_printk(KERN_INFO, sdp,
626629
"sg_write: scsi opcode=0x%02x, cmd_size=%d\n", (int) opcode, cmd_size));
627630
/* Determine buffer size. */
@@ -721,7 +724,7 @@ sg_new_write(Sg_fd *sfp, struct file *file, const char __user *buf,
721724
sg_remove_request(sfp, srp);
722725
return -EINVAL; /* either MMAP_IO or DIRECT_IO (not both) */
723726
}
724-
if (sg_res_in_use(sfp)) {
727+
if (sfp->res_in_use) {
725728
sg_remove_request(sfp, srp);
726729
return -EBUSY; /* reserve buffer already being used */
727730
}
@@ -892,7 +895,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
892895
return result;
893896
if (val) {
894897
sfp->low_dma = 1;
895-
if ((0 == sfp->low_dma) && (0 == sg_res_in_use(sfp))) {
898+
if ((0 == sfp->low_dma) && !sfp->res_in_use) {
896899
val = (int) sfp->reserve.bufflen;
897900
sg_remove_scat(sfp, &sfp->reserve);
898901
sg_build_reserve(sfp, val);
@@ -967,12 +970,18 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
967970
return -EINVAL;
968971
val = min_t(int, val,
969972
max_sectors_bytes(sdp->device->request_queue));
973+
mutex_lock(&sfp->f_mutex);
970974
if (val != sfp->reserve.bufflen) {
971-
if (sg_res_in_use(sfp) || sfp->mmap_called)
975+
if (sfp->mmap_called ||
976+
sfp->res_in_use) {
977+
mutex_unlock(&sfp->f_mutex);
972978
return -EBUSY;
979+
}
980+
973981
sg_remove_scat(sfp, &sfp->reserve);
974982
sg_build_reserve(sfp, val);
975983
}
984+
mutex_unlock(&sfp->f_mutex);
976985
return 0;
977986
case SG_GET_RESERVED_SIZE:
978987
val = min_t(int, sfp->reserve.bufflen,
@@ -1727,13 +1736,22 @@ sg_start_req(Sg_request *srp, unsigned char *cmd)
17271736
md = &map_data;
17281737

17291738
if (md) {
1730-
if (!sg_res_in_use(sfp) && dxfer_len <= rsv_schp->bufflen)
1739+
mutex_lock(&sfp->f_mutex);
1740+
if (dxfer_len <= rsv_schp->bufflen &&
1741+
!sfp->res_in_use) {
1742+
sfp->res_in_use = 1;
17311743
sg_link_reserve(sfp, srp, dxfer_len);
1732-
else {
1744+
} else if ((hp->flags & SG_FLAG_MMAP_IO) && sfp->res_in_use) {
1745+
mutex_unlock(&sfp->f_mutex);
1746+
return -EBUSY;
1747+
} else {
17331748
res = sg_build_indirect(req_schp, sfp, dxfer_len);
1734-
if (res)
1749+
if (res) {
1750+
mutex_unlock(&sfp->f_mutex);
17351751
return res;
1752+
}
17361753
}
1754+
mutex_unlock(&sfp->f_mutex);
17371755

17381756
md->pages = req_schp->pages;
17391757
md->page_order = req_schp->page_order;
@@ -2024,6 +2042,8 @@ sg_unlink_reserve(Sg_fd * sfp, Sg_request * srp)
20242042
req_schp->sglist_len = 0;
20252043
sfp->save_scat_len = 0;
20262044
srp->res_used = 0;
2045+
/* Called without mutex lock to avoid deadlock */
2046+
sfp->res_in_use = 0;
20272047
}
20282048

20292049
static Sg_request *
@@ -2135,6 +2155,7 @@ sg_add_sfp(Sg_device * sdp)
21352155
rwlock_init(&sfp->rq_list_lock);
21362156

21372157
kref_init(&sfp->f_ref);
2158+
mutex_init(&sfp->f_mutex);
21382159
sfp->timeout = SG_DEFAULT_TIMEOUT;
21392160
sfp->timeout_user = SG_DEFAULT_TIMEOUT_USER;
21402161
sfp->force_packid = SG_DEF_FORCE_PACK_ID;
@@ -2210,20 +2231,6 @@ sg_remove_sfp(struct kref *kref)
22102231
schedule_work(&sfp->ew.work);
22112232
}
22122233

2213-
static int
2214-
sg_res_in_use(Sg_fd * sfp)
2215-
{
2216-
const Sg_request *srp;
2217-
unsigned long iflags;
2218-
2219-
read_lock_irqsave(&sfp->rq_list_lock, iflags);
2220-
for (srp = sfp->headrp; srp; srp = srp->nextrp)
2221-
if (srp->res_used)
2222-
break;
2223-
read_unlock_irqrestore(&sfp->rq_list_lock, iflags);
2224-
return srp ? 1 : 0;
2225-
}
2226-
22272234
#ifdef CONFIG_SCSI_PROC_FS
22282235
static int
22292236
sg_idr_max_id(int id, void *p, void *data)

drivers/staging/wilc1000/linux_wlan.c

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -269,23 +269,12 @@ static struct net_device *get_if_handler(struct wilc *wilc, u8 *mac_header)
269269

270270
int wilc_wlan_set_bssid(struct net_device *wilc_netdev, u8 *bssid, u8 mode)
271271
{
272-
int i = 0;
273-
int ret = -1;
274-
struct wilc_vif *vif;
275-
struct wilc *wilc;
276-
277-
vif = netdev_priv(wilc_netdev);
278-
wilc = vif->wilc;
272+
struct wilc_vif *vif = netdev_priv(wilc_netdev);
279273

280-
for (i = 0; i < wilc->vif_num; i++)
281-
if (wilc->vif[i]->ndev == wilc_netdev) {
282-
memcpy(wilc->vif[i]->bssid, bssid, 6);
283-
wilc->vif[i]->mode = mode;
284-
ret = 0;
285-
break;
286-
}
274+
memcpy(vif->bssid, bssid, 6);
275+
vif->mode = mode;
287276

288-
return ret;
277+
return 0;
289278
}
290279

291280
int wilc_wlan_get_num_conn_ifcs(struct wilc *wilc)
@@ -1212,16 +1201,11 @@ void WILC_WFI_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size)
12121201

12131202
void wilc_netdev_cleanup(struct wilc *wilc)
12141203
{
1215-
int i = 0;
1216-
struct wilc_vif *vif[NUM_CONCURRENT_IFC];
1204+
int i;
12171205

1218-
if (wilc && (wilc->vif[0]->ndev || wilc->vif[1]->ndev)) {
1206+
if (wilc && (wilc->vif[0]->ndev || wilc->vif[1]->ndev))
12191207
unregister_inetaddr_notifier(&g_dev_notifier);
12201208

1221-
for (i = 0; i < NUM_CONCURRENT_IFC; i++)
1222-
vif[i] = netdev_priv(wilc->vif[i]->ndev);
1223-
}
1224-
12251209
if (wilc && wilc->firmware) {
12261210
release_firmware(wilc->firmware);
12271211
wilc->firmware = NULL;
@@ -1230,7 +1214,7 @@ void wilc_netdev_cleanup(struct wilc *wilc)
12301214
if (wilc && (wilc->vif[0]->ndev || wilc->vif[1]->ndev)) {
12311215
for (i = 0; i < NUM_CONCURRENT_IFC; i++)
12321216
if (wilc->vif[i]->ndev)
1233-
if (vif[i]->mac_opened)
1217+
if (wilc->vif[i]->mac_opened)
12341218
wilc_mac_close(wilc->vif[i]->ndev);
12351219

12361220
for (i = 0; i < NUM_CONCURRENT_IFC; i++) {
@@ -1278,9 +1262,9 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type,
12781262

12791263
vif->idx = wl->vif_num;
12801264
vif->wilc = *wilc;
1265+
vif->ndev = ndev;
12811266
wl->vif[i] = vif;
1282-
wl->vif[wl->vif_num]->ndev = ndev;
1283-
wl->vif_num++;
1267+
wl->vif_num = i;
12841268
ndev->netdev_ops = &wilc_netdev_ops;
12851269

12861270
{

kernel/gcov/base.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ void __gcov_merge_icall_topn(gcov_type *counters, unsigned int n_counters)
9898
}
9999
EXPORT_SYMBOL(__gcov_merge_icall_topn);
100100

101+
void __gcov_exit(void)
102+
{
103+
/* Unused. */
104+
}
105+
EXPORT_SYMBOL(__gcov_exit);
106+
101107
/**
102108
* gcov_enable_events - enable event reporting through gcov_event()
103109
*

kernel/gcov/gcc_4_7.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
#include <linux/vmalloc.h>
1919
#include "gcov.h"
2020

21-
#if (__GNUC__ > 5) || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1)
21+
#if (__GNUC__ >= 7)
22+
#define GCOV_COUNTERS 9
23+
#elif (__GNUC__ > 5) || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1)
2224
#define GCOV_COUNTERS 10
2325
#elif __GNUC__ == 4 && __GNUC_MINOR__ >= 9
2426
#define GCOV_COUNTERS 9

0 commit comments

Comments
 (0)