Skip to content

Commit

Permalink
drivers: Initialize resource entry to zero
Browse files Browse the repository at this point in the history
I/O resource descriptor, 'desc' in struct resource, needs to be
initialized to zero by default.  Some drivers call kmalloc() to
allocate a resource entry, but do not initialize it to zero by
memset().  Change these drivers to call kzalloc(), instead.

Signed-off-by: Toshi Kani <[email protected]>
Signed-off-by: Borislav Petkov <[email protected]>
Acked-by: Alexandre Bounine <[email protected]>
Acked-by: Helge Deller <[email protected]>
Acked-by: Rafael J. Wysocki <[email protected]>
Acked-by: Simon Horman <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Andy Lutomirski <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Brian Gerst <[email protected]>
Cc: Denys Vlasenko <[email protected]>
Cc: H. Peter Anvin <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Luis R. Rodriguez <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Toshi Kani <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: linux-mm <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
  • Loading branch information
toshikani authored and Ingo Molnar committed Jan 30, 2016
1 parent 782b866 commit 9a975be
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion drivers/acpi/acpi_platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev)
if (count < 0) {
return NULL;
} else if (count > 0) {
resources = kmalloc(count * sizeof(struct resource),
resources = kzalloc(count * sizeof(struct resource),
GFP_KERNEL);
if (!resources) {
dev_err(&adev->dev, "No memory for resources\n");
Expand Down
4 changes: 2 additions & 2 deletions drivers/parisc/eisa_enumerator.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ static int configure_memory(const unsigned char *buf,
for (i=0;i<HPEE_MEMORY_MAX_ENT;i++) {
c = get_8(buf+len);

if (NULL != (res = kmalloc(sizeof(struct resource), GFP_KERNEL))) {
if (NULL != (res = kzalloc(sizeof(struct resource), GFP_KERNEL))) {
int result;

res->name = name;
Expand Down Expand Up @@ -183,7 +183,7 @@ static int configure_port(const unsigned char *buf, struct resource *io_parent,
for (i=0;i<HPEE_PORT_MAX_ENT;i++) {
c = get_8(buf+len);

if (NULL != (res = kmalloc(sizeof(struct resource), GFP_KERNEL))) {
if (NULL != (res = kzalloc(sizeof(struct resource), GFP_KERNEL))) {
res->name = board;
res->start = get_16(buf+len+1);
res->end = get_16(buf+len+1)+(c&HPEE_PORT_SIZE_MASK)+1;
Expand Down
8 changes: 4 additions & 4 deletions drivers/rapidio/rio.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ int rio_request_inb_mbox(struct rio_mport *mport,
if (mport->ops->open_inb_mbox == NULL)
goto out;

res = kmalloc(sizeof(struct resource), GFP_KERNEL);
res = kzalloc(sizeof(struct resource), GFP_KERNEL);

if (res) {
rio_init_mbox_res(res, mbox, mbox);
Expand Down Expand Up @@ -185,7 +185,7 @@ int rio_request_outb_mbox(struct rio_mport *mport,
if (mport->ops->open_outb_mbox == NULL)
goto out;

res = kmalloc(sizeof(struct resource), GFP_KERNEL);
res = kzalloc(sizeof(struct resource), GFP_KERNEL);

if (res) {
rio_init_mbox_res(res, mbox, mbox);
Expand Down Expand Up @@ -285,7 +285,7 @@ int rio_request_inb_dbell(struct rio_mport *mport,
{
int rc = 0;

struct resource *res = kmalloc(sizeof(struct resource), GFP_KERNEL);
struct resource *res = kzalloc(sizeof(struct resource), GFP_KERNEL);

if (res) {
rio_init_dbell_res(res, start, end);
Expand Down Expand Up @@ -360,7 +360,7 @@ int rio_release_inb_dbell(struct rio_mport *mport, u16 start, u16 end)
struct resource *rio_request_outb_dbell(struct rio_dev *rdev, u16 start,
u16 end)
{
struct resource *res = kmalloc(sizeof(struct resource), GFP_KERNEL);
struct resource *res = kzalloc(sizeof(struct resource), GFP_KERNEL);

if (res) {
rio_init_dbell_res(res, start, end);
Expand Down
2 changes: 1 addition & 1 deletion drivers/sh/superhyway/superhyway.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ int superhyway_add_device(unsigned long base, struct superhyway_device *sdev,
superhyway_read_vcr(dev, base, &dev->vcr);

if (!dev->resource) {
dev->resource = kmalloc(sizeof(struct resource), GFP_KERNEL);
dev->resource = kzalloc(sizeof(struct resource), GFP_KERNEL);
if (!dev->resource) {
kfree(dev);
return -ENOMEM;
Expand Down

0 comments on commit 9a975be

Please sign in to comment.