Skip to content

Commit e255759

Browse files
committed
Merge tag 'char-misc-5.17-rc2' of git://git.kernel.org/pub/scm/linux/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
2 parents bb37101 + fc55e63 commit e255759

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

drivers/counter/counter-core.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,8 @@ struct counter_device *counter_alloc(size_t sizeof_priv)
9090
int err;
9191

9292
ch = kzalloc(sizeof(*ch) + sizeof_priv, GFP_KERNEL);
93-
if (!ch) {
94-
err = -ENOMEM;
95-
goto err_alloc_ch;
96-
}
93+
if (!ch)
94+
return NULL;
9795

9896
counter = &ch->counter;
9997
dev = &counter->dev;
@@ -123,9 +121,8 @@ struct counter_device *counter_alloc(size_t sizeof_priv)
123121
err_ida_alloc:
124122

125123
kfree(ch);
126-
err_alloc_ch:
127124

128-
return ERR_PTR(err);
125+
return NULL;
129126
}
130127
EXPORT_SYMBOL_GPL(counter_alloc);
131128

@@ -208,12 +205,12 @@ struct counter_device *devm_counter_alloc(struct device *dev, size_t sizeof_priv
208205
int err;
209206

210207
counter = counter_alloc(sizeof_priv);
211-
if (IS_ERR(counter))
212-
return counter;
208+
if (!counter)
209+
return NULL;
213210

214211
err = devm_add_action_or_reset(dev, devm_counter_put, counter);
215212
if (err < 0)
216-
return ERR_PTR(err);
213+
return NULL;
217214

218215
return counter;
219216
}

drivers/misc/eeprom/at25.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,10 @@ static int at25_probe(struct spi_device *spi)
440440
return -ENXIO;
441441
}
442442

443+
at25 = devm_kzalloc(&spi->dev, sizeof(*at25), GFP_KERNEL);
444+
if (!at25)
445+
return -ENOMEM;
446+
443447
mutex_init(&at25->lock);
444448
at25->spi = spi;
445449
spi_set_drvdata(spi, at25);

0 commit comments

Comments
 (0)