Skip to content

Commit c4142ed

Browse files
committed
Merge tag 'driver-core-4.14-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core
Pull driver core fixes from Greg KH: "Here are a few small fixes for 4.14-rc4. The removal of DRIVER_ATTR() was almost completed by 4.14-rc1, but one straggler made it in through some other tree (odds are, one of mine...) So there's a simple removal of the last user, and then finally the macro is removed from the tree. There's a fix for old crazy udev instances that insist on reloading a module when it is removed from the kernel due to the new uevents for bind/unbind. This fixes the reported regression, hopefully some year in the future we can drop the workaround, once users update to the latest version, but I'm not holding my breath. And then there's a build fix for a linker warning, and a buffer overflow fix to match the PCI fixes you took through the PCI tree in the same area. All of these have been in linux-next for a few weeks while I've been traveling, sorry for the delay" * tag 'driver-core-4.14-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: driver core: remove DRIVER_ATTR fpga: altera-cvp: remove DRIVER_ATTR() usage driver core: platform: Don't read past the end of "driver_override" buffer base: arch_topology: fix section mismatch build warnings driver core: suppress sending MODALIAS in UNBIND uevents
2 parents 3a98be0 + 850fdec commit c4142ed

File tree

7 files changed

+58
-24
lines changed

7 files changed

+58
-24
lines changed

Documentation/driver-model/driver.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,13 @@ struct driver_attribute {
196196
};
197197

198198
Device drivers can export attributes via their sysfs directories.
199-
Drivers can declare attributes using a DRIVER_ATTR macro that works
200-
identically to the DEVICE_ATTR macro.
199+
Drivers can declare attributes using a DRIVER_ATTR_RW and DRIVER_ATTR_RO
200+
macro that works identically to the DEVICE_ATTR_RW and DEVICE_ATTR_RO
201+
macros.
201202

202203
Example:
203204

204-
DRIVER_ATTR(debug,0644,show_debug,store_debug);
205+
DRIVER_ATTR_RW(debug);
205206

206207
This is equivalent to declaring:
207208

Documentation/filesystems/sysfs.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,8 @@ struct driver_attribute {
366366

367367
Declaring:
368368

369-
DRIVER_ATTR(_name, _mode, _show, _store)
369+
DRIVER_ATTR_RO(_name)
370+
DRIVER_ATTR_RW(_name)
370371

371372
Creation/Removal:
372373

drivers/base/arch_topology.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,11 @@ bool __init topology_parse_cpu_capacity(struct device_node *cpu_node, int cpu)
166166
}
167167

168168
#ifdef CONFIG_CPU_FREQ
169-
static cpumask_var_t cpus_to_visit;
170-
static void parsing_done_workfn(struct work_struct *work);
171-
static DECLARE_WORK(parsing_done_work, parsing_done_workfn);
169+
static cpumask_var_t cpus_to_visit __initdata;
170+
static void __init parsing_done_workfn(struct work_struct *work);
171+
static __initdata DECLARE_WORK(parsing_done_work, parsing_done_workfn);
172172

173-
static int
173+
static int __init
174174
init_cpu_capacity_callback(struct notifier_block *nb,
175175
unsigned long val,
176176
void *data)
@@ -206,7 +206,7 @@ init_cpu_capacity_callback(struct notifier_block *nb,
206206
return 0;
207207
}
208208

209-
static struct notifier_block init_cpu_capacity_notifier = {
209+
static struct notifier_block init_cpu_capacity_notifier __initdata = {
210210
.notifier_call = init_cpu_capacity_callback,
211211
};
212212

@@ -232,7 +232,7 @@ static int __init register_cpufreq_notifier(void)
232232
}
233233
core_initcall(register_cpufreq_notifier);
234234

235-
static void parsing_done_workfn(struct work_struct *work)
235+
static void __init parsing_done_workfn(struct work_struct *work)
236236
{
237237
cpufreq_unregister_notifier(&init_cpu_capacity_notifier,
238238
CPUFREQ_POLICY_NOTIFIER);

drivers/base/platform.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,8 @@ static ssize_t driver_override_store(struct device *dev,
868868
struct platform_device *pdev = to_platform_device(dev);
869869
char *driver_override, *old, *cp;
870870

871-
if (count > PATH_MAX)
871+
/* We need to keep extra room for a newline */
872+
if (count >= (PAGE_SIZE - 1))
872873
return -EINVAL;
873874

874875
driver_override = kstrndup(buf, count, GFP_KERNEL);

drivers/fpga/altera-cvp.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,12 +361,12 @@ static const struct fpga_manager_ops altera_cvp_ops = {
361361
.write_complete = altera_cvp_write_complete,
362362
};
363363

364-
static ssize_t show_chkcfg(struct device_driver *dev, char *buf)
364+
static ssize_t chkcfg_show(struct device_driver *dev, char *buf)
365365
{
366366
return snprintf(buf, 3, "%d\n", altera_cvp_chkcfg);
367367
}
368368

369-
static ssize_t store_chkcfg(struct device_driver *drv, const char *buf,
369+
static ssize_t chkcfg_store(struct device_driver *drv, const char *buf,
370370
size_t count)
371371
{
372372
int ret;
@@ -378,7 +378,7 @@ static ssize_t store_chkcfg(struct device_driver *drv, const char *buf,
378378
return count;
379379
}
380380

381-
static DRIVER_ATTR(chkcfg, 0600, show_chkcfg, store_chkcfg);
381+
static DRIVER_ATTR_RW(chkcfg);
382382

383383
static int altera_cvp_probe(struct pci_dev *pdev,
384384
const struct pci_device_id *dev_id);

include/linux/device.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,6 @@ struct driver_attribute {
307307
size_t count);
308308
};
309309

310-
#define DRIVER_ATTR(_name, _mode, _show, _store) \
311-
struct driver_attribute driver_attr_##_name = __ATTR(_name, _mode, _show, _store)
312310
#define DRIVER_ATTR_RW(_name) \
313311
struct driver_attribute driver_attr_##_name = __ATTR_RW(_name)
314312
#define DRIVER_ATTR_RO(_name) \

lib/kobject_uevent.c

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,26 @@ static void cleanup_uevent_env(struct subprocess_info *info)
294294
}
295295
#endif
296296

297+
static void zap_modalias_env(struct kobj_uevent_env *env)
298+
{
299+
static const char modalias_prefix[] = "MODALIAS=";
300+
int i;
301+
302+
for (i = 0; i < env->envp_idx;) {
303+
if (strncmp(env->envp[i], modalias_prefix,
304+
sizeof(modalias_prefix) - 1)) {
305+
i++;
306+
continue;
307+
}
308+
309+
if (i != env->envp_idx - 1)
310+
memmove(&env->envp[i], &env->envp[i + 1],
311+
sizeof(env->envp[i]) * env->envp_idx - 1);
312+
313+
env->envp_idx--;
314+
}
315+
}
316+
297317
/**
298318
* kobject_uevent_env - send an uevent with environmental data
299319
*
@@ -409,16 +429,29 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
409429
}
410430
}
411431

412-
/*
413-
* Mark "add" and "remove" events in the object to ensure proper
414-
* events to userspace during automatic cleanup. If the object did
415-
* send an "add" event, "remove" will automatically generated by
416-
* the core, if not already done by the caller.
417-
*/
418-
if (action == KOBJ_ADD)
432+
switch (action) {
433+
case KOBJ_ADD:
434+
/*
435+
* Mark "add" event so we can make sure we deliver "remove"
436+
* event to userspace during automatic cleanup. If
437+
* the object did send an "add" event, "remove" will
438+
* automatically generated by the core, if not already done
439+
* by the caller.
440+
*/
419441
kobj->state_add_uevent_sent = 1;
420-
else if (action == KOBJ_REMOVE)
442+
break;
443+
444+
case KOBJ_REMOVE:
421445
kobj->state_remove_uevent_sent = 1;
446+
break;
447+
448+
case KOBJ_UNBIND:
449+
zap_modalias_env(env);
450+
break;
451+
452+
default:
453+
break;
454+
}
422455

423456
mutex_lock(&uevent_sock_mutex);
424457
/* we will send an event, so request a new sequence number */

0 commit comments

Comments
 (0)