Commit graph

12 commits

Author SHA1 Message Date
Dan Carpenter
b7db58105b staging: greybus: use after free in gb_audio_manager_remove_all()
When we call kobject_put() and it's the last reference to the kobject
then it calls gb_audio_module_release() and frees module.  We dereference
"module" on the next line which is a use after free.

Fixes: c77f85bbc9 ("greybus: audio: Fix incorrect counting of 'ida'")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Link: https://lore.kernel.org/r/20200205123217.jreendkyxulqsool@kili.mountain
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-02-10 08:52:33 -08:00
Colin Ian King
e192832735 staging: greybus: remove redundant assignment to variable is_empty
The variable is_empty is being initialized with a value that is never
read and it is being updated later with a new value. The
initialization is redundant and can be removed.

Addresses-Coverity: ("Unused value")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Link: https://lore.kernel.org/r/20190704133031.28809-1-colin.king@canonical.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-07-22 07:34:10 +02:00
Kangjie Lu
b5af36e3e5 staging: greybus: audio_manager: fix a missing check of ida_simple_get
ida_simple_get could fail. The fix inserts a check for its
return value.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
Reviewed-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-03-29 17:28:48 +01:00
Greg Kroah-Hartman
863dbc52e7 staging: greybus: Remove redundant license text
Now that the SPDX tag is in all greybus files, that identifies the
license in a specific and legally-defined manner.  So the extra GPL text
wording can be removed as it is no longer needed at all.

This is done on a quest to remove the 700+ different ways that files in
the kernel describe the GPL license text.  And there's unneeded stuff
like the address (sometimes incorrect) for the FSF which is never
needed.

No copyright headers or other non-license-description text was removed.

Cc: Vaibhav Hiremath <hvaibhav.linux@gmail.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Acked-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Acked-by: David Lin <dtwlin@gmail.com>
Acked-by: Johan Hovold <johan@kernel.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Mark Greer <mgreer@animalcreek.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Acked-by: "Bryan O'Donoghue" <pure.logic@nexus-software.ie>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-11 14:46:21 +01:00
Greg Kroah-Hartman
eb50fd3a22 staging: greybus: add SPDX identifiers to all greybus driver files
It's good to have SPDX identifiers in all files to make it easier to
audit the kernel tree for correct licenses.

Update the drivers/staging/greybus files files with the correct SPDX
license identifier based on the license text in the file itself.  The
SPDX identifier is a legally binding shorthand, which can be used
instead of the full boiler plate text.

This work is based on a script and data from Thomas Gleixner, Philippe
Ombredanne, and Kate Stewart.

Cc: Vaibhav Hiremath <hvaibhav.linux@gmail.com>
Cc: "Bryan O'Donoghue" <pure.logic@nexus-software.ie>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Kate Stewart <kstewart@linuxfoundation.org>
Cc: Philippe Ombredanne <pombredanne@nexb.com>
Acked-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Acked-by: David Lin <dtwlin@gmail.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Acked-by: Johan Hovold <johan@kernel.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Mark Greer <mgreer@animalcreek.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-11 14:46:20 +01:00
Sebastian Andrzej Siewior
2d10b85704 greybus: audio: don't inclide rwlock.h directly.
rwlock.h should not be included directly. Instead linux/splinlock.h
should be included. One thing it does is to break the RT build.

Cc: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Cc: Johan Hovold <johan@kernel.org>
Cc: Alex Elder <elder@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: greybus-dev@lists.linaro.org
Cc: devel@driverdev.osuosl.org
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-18 16:42:28 +02:00
Vaibhav Agarwal
ac00154a7c greybus: audio: gb_manager: Use valid argument while removing ida allocated id.
module->id is used as an argument to ida_simple_remove(). Since module
is already dereferenced, module->id might contain invalid data. So fix
this.

Fixes: da4cc2d0b066 ("audio:gb_manager: Use proper locking around kobject_xxx")
Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-18 16:33:31 -07:00
Dinko Mironov
c77f85bbc9 greybus: audio: Fix incorrect counting of 'ida'
Function gb_audio_manager_remove_all() to remove all audio modules,
doesn't control correctly 'ida' counting.

Signed-off-by: Dinko Mironov <dmironov@mm-sol.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-05 13:33:20 -07:00
Vaibhav Agarwal
84e0e38744 greybus: audio:gb_manager: Use proper locking around kobject_xxx
read/write_lock_irqsave mechanism was used to protect modules
list & kobject_xxx() in gb_audio_manager. Since kobject_xxx calls
can sleep spin_lock variants can't be used there. So use rw_sem
for protecting modules_list.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-04 11:29:06 -07:00
Bartosz Golaszewski
ec413566e8 greybus: audio_manager: add missing header
There's a definition missing in audio_manager causing the kernel build
to fail:

  CC [M]  ./greybus/audio_manager.o
./greybus/audio_manager.c:22:8: warning: type defaults to 'int' in declaration of 'DEFINE_IDA' [-Wimplicit-int]
error, forbidden warning: audio_manager.c:22
./kernel/scripts/Makefile.build:308: recipe for target './greybus/audio_manager.o' failed

Including linux/idr.h fixes the issue.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-02-03 10:38:54 -08:00
Greg Kroah-Hartman
3c5de59473 greybus: audio_manager: use an 'ida' for the module id
Every time we hotplug an audio module, we get a new audio module id.  We
should recycle them instead of just constantly incrementing the number
so we don't see things like:
	[178016.832580] Created audio module #6124
in the kernel logs.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-02-02 21:26:32 -08:00
Svetlin Ankov
8db00736d3 greybus: audio: Add Audio Manager
This is a simple module that keeps a list of connected GB audio
modules.

Whenever a device is attached, an appropriate uevent is sent to
userspace:

    UDEV  [4941.803215] add      /kernel/gb_audio_manager/0 (gb_audio_manager)
    ACTION=add
    CPORT=99
    DEVICES=0x10
    DEVPATH=/kernel/gb_audio_manager/0
    NAME=naim
    PID=64
    SEQNUM=1828
    SLOT=2
    SUBSYSTEM=gb_audio_manager
    USEC_INITIALIZED=802416
    VID=128

And whenever removed:

    UDEV  [4941.836588] remove   /kernel/gb_audio_manager/0 (gb_audio_manager)
    ACTION=remove
    DEVPATH=/kernel/gb_audio_manager/0
    SEQNUM=1833
    SUBSYSTEM=gb_audio_manager
    USEC_INITIALIZED=835681

The API consists of functions for adding, removing and inspecting
added device module descriptions (struct gb_audio_module):

    int                         gb_audio_manager_add(struct gb_audio_module_descriptor *desc);
    int                         gb_audio_manager_remove(int id);
    int                         gb_audio_manager_remove_all(void);
    struct  gb_audio_module*    gb_audio_manager_get_module(int id);
    void                        gb_audio_manager_put_module(struct gb_audio_module *module);
    int                         gb_audio_manager_dump_module(int id);
    void                        gb_audio_manager_dump_all(void);

Devices can be inspected through sysfs in /sys/kernel/gb_audio_manager/{id}/*

If GB_AUDIO_MANAGER_SYSFS is exported as 'true', managing devices can be done
via the SYSFS as well. For instance:

    echo name=naim slot=2 vid=128 pid=64 cport=99 devices=0x10 > /sys/kernel/gb_audio_manager/add
    echo all > /sys/kernel/gb_audio_manager/dump
    echo 2 > /sys/kernel/gb_audio_manager/dump
    echo 2 > /sys/kernel/gb_audio_manager/remove

Signed-off-by: Svetlin Ankov <ankov_svetlin@projectara.com>
Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-01-13 16:12:56 -08:00