Skip to content

Commit

Permalink
Merge tag 'char-misc-5.17-rc2' of git://git.kernel.org/pub/scm/linux/…
Browse files Browse the repository at this point in the history
…kernel/git/gregkh/char-misc

Pull char/misc driver fixes from Greg KH:
 "Here are two small char/misc driver fixes for 5.17-rc2 that fix some
  reported issues. They are:

   - fix up a merge issue in the at25.c driver that ended up dropping
     some lines in the driver. The removed lines ended being needed, so
     this restores it and the driver works again.

   - counter core fix where the wrong error was being returned, NULL
     should be the correct error for when memory is gone here, like the
     kmalloc() core does.

  Both of these have been in linux-next this week with no reported
  issues"

* tag 'char-misc-5.17-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc:
  counter: fix an IS_ERR() vs NULL bug
  eeprom: at25: Restore missing allocation
  • Loading branch information
Linus Torvalds committed Jan 29, 2022
2 parents bb37101 + fc55e63 commit e255759
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
15 changes: 6 additions & 9 deletions drivers/counter/counter-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,8 @@ struct counter_device *counter_alloc(size_t sizeof_priv)
int err;

ch = kzalloc(sizeof(*ch) + sizeof_priv, GFP_KERNEL);
if (!ch) {
err = -ENOMEM;
goto err_alloc_ch;
}
if (!ch)
return NULL;

counter = &ch->counter;
dev = &counter->dev;
Expand Down Expand Up @@ -123,9 +121,8 @@ struct counter_device *counter_alloc(size_t sizeof_priv)
err_ida_alloc:

kfree(ch);
err_alloc_ch:

return ERR_PTR(err);
return NULL;
}
EXPORT_SYMBOL_GPL(counter_alloc);

Expand Down Expand Up @@ -208,12 +205,12 @@ struct counter_device *devm_counter_alloc(struct device *dev, size_t sizeof_priv
int err;

counter = counter_alloc(sizeof_priv);
if (IS_ERR(counter))
return counter;
if (!counter)
return NULL;

err = devm_add_action_or_reset(dev, devm_counter_put, counter);
if (err < 0)
return ERR_PTR(err);
return NULL;

return counter;
}
Expand Down
4 changes: 4 additions & 0 deletions drivers/misc/eeprom/at25.c
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,10 @@ static int at25_probe(struct spi_device *spi)
return -ENXIO;
}

at25 = devm_kzalloc(&spi->dev, sizeof(*at25), GFP_KERNEL);
if (!at25)
return -ENOMEM;

mutex_init(&at25->lock);
at25->spi = spi;
spi_set_drvdata(spi, at25);
Expand Down

0 comments on commit e255759

Please sign in to comment.