Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ef19df6

Browse files
committed
Merge tag 'char-misc-4.3-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc
Pull char/misc driver fixes from Greg KH: "Here are some small fixes for some misc drivers that resolve some reported issues. All of these have been linux-next for a while" * tag 'char-misc-4.3-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: mcb: Fix error handling in mcb_pci_probe() mei: hbm: fix error in state check logic nvmem: sunxi: Check for memory allocation failure nvmem: core: Fix memory leak in nvmem_cell_write nvmem: core: Handle shift bits in-place if cell->nbits is non-zero nvmem: core: fix the out-of-range leak in read/write()
2 parents bbecce8 + 41ada9d commit ef19df6

File tree

4 files changed

+19
-8
lines changed

4 files changed

+19
-8
lines changed

drivers/mcb/mcb-pci.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ static int mcb_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
7474
ret = -ENOTSUPP;
7575
dev_err(&pdev->dev,
7676
"IO mapped PCI devices are not supported\n");
77-
goto out_release;
77+
goto out_iounmap;
7878
}
7979

8080
pci_set_drvdata(pdev, priv);
@@ -89,7 +89,7 @@ static int mcb_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
8989

9090
ret = chameleon_parse_cells(priv->bus, priv->mapbase, priv->base);
9191
if (ret < 0)
92-
goto out_iounmap;
92+
goto out_mcb_bus;
9393
num_cells = ret;
9494

9595
dev_dbg(&pdev->dev, "Found %d cells\n", num_cells);
@@ -98,6 +98,8 @@ static int mcb_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
9898

9999
return 0;
100100

101+
out_mcb_bus:
102+
mcb_release_bus(priv->bus);
101103
out_iounmap:
102104
iounmap(priv->base);
103105
out_release:

drivers/misc/mei/hbm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1209,7 +1209,7 @@ int mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr)
12091209
* after the host receives the enum_resp
12101210
* message clients may be added or removed
12111211
*/
1212-
if (dev->hbm_state <= MEI_HBM_ENUM_CLIENTS &&
1212+
if (dev->hbm_state <= MEI_HBM_ENUM_CLIENTS ||
12131213
dev->hbm_state >= MEI_HBM_STOPPED) {
12141214
dev_err(dev->dev, "hbm: add client: state mismatch, [%d, %d]\n",
12151215
dev->dev_state, dev->hbm_state);

drivers/nvmem/core.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static ssize_t bin_attr_nvmem_read(struct file *filp, struct kobject *kobj,
6767
int rc;
6868

6969
/* Stop the user from reading */
70-
if (pos > nvmem->size)
70+
if (pos >= nvmem->size)
7171
return 0;
7272

7373
if (pos + count > nvmem->size)
@@ -92,7 +92,7 @@ static ssize_t bin_attr_nvmem_write(struct file *filp, struct kobject *kobj,
9292
int rc;
9393

9494
/* Stop the user from writing */
95-
if (pos > nvmem->size)
95+
if (pos >= nvmem->size)
9696
return 0;
9797

9898
if (pos + count > nvmem->size)
@@ -825,7 +825,7 @@ static int __nvmem_cell_read(struct nvmem_device *nvmem,
825825
return rc;
826826

827827
/* shift bits in-place */
828-
if (cell->bit_offset || cell->bit_offset)
828+
if (cell->bit_offset || cell->nbits)
829829
nvmem_shift_read_buffer_in_place(cell, buf);
830830

831831
*len = cell->bytes;
@@ -938,7 +938,7 @@ int nvmem_cell_write(struct nvmem_cell *cell, void *buf, size_t len)
938938
rc = regmap_raw_write(nvmem->regmap, cell->offset, buf, cell->bytes);
939939

940940
/* free the tmp buffer */
941-
if (cell->bit_offset)
941+
if (cell->bit_offset || cell->nbits)
942942
kfree(buf);
943943

944944
if (IS_ERR_VALUE(rc))

drivers/nvmem/sunxi_sid.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ static int sunxi_sid_probe(struct platform_device *pdev)
103103
struct nvmem_device *nvmem;
104104
struct regmap *regmap;
105105
struct sunxi_sid *sid;
106-
int i, size;
106+
int ret, i, size;
107107
char *randomness;
108108

109109
sid = devm_kzalloc(dev, sizeof(*sid), GFP_KERNEL);
@@ -131,6 +131,11 @@ static int sunxi_sid_probe(struct platform_device *pdev)
131131
return PTR_ERR(nvmem);
132132

133133
randomness = kzalloc(sizeof(u8) * size, GFP_KERNEL);
134+
if (!randomness) {
135+
ret = -EINVAL;
136+
goto err_unreg_nvmem;
137+
}
138+
134139
for (i = 0; i < size; i++)
135140
randomness[i] = sunxi_sid_read_byte(sid, i);
136141

@@ -140,6 +145,10 @@ static int sunxi_sid_probe(struct platform_device *pdev)
140145
platform_set_drvdata(pdev, nvmem);
141146

142147
return 0;
148+
149+
err_unreg_nvmem:
150+
nvmem_unregister(nvmem);
151+
return ret;
143152
}
144153

145154
static int sunxi_sid_remove(struct platform_device *pdev)

0 commit comments

Comments
 (0)