Skip to content

Commit e97c618

Browse files
committed
Merge tag 'mtd/fixes-for-6.18-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux
Pull MTD fixes from Miquel Raynal: "Mostly small misc fixes, here they are sorted by sub-subsystem: ECC fixes: - Realtek Kconfig fix SPI NAND fixes: - Remove nonexistent QE bit on FMSH FM25S01A Raw NAND fixes: - Prevent DMA device NULL pointer dereference in Cadence driver MTD device fixes: - Possible integer overflow in read/write ioctls - Fix the IRQ handler pointer in the onenand driver, even if in practice it is never dereferenced. * tag 'mtd/fixes-for-6.18-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux: mtd: onenand: Pass correct pointer to IRQ handler mtd: spinand: fmsh: remove QE bit for FM25S01A flash mtd: rawnand: cadence: fix DMA device NULL pointer dereference mtd: rawnand: realtek: Make rtl_ecc_engine_ops const mtd: nand: MTD_NAND_ECC_REALTEK should depend on HAS_DMA mtd: nand: realtek-ecc: Fix a IS_ERR() vs NULL bug in probe mtdchar: fix integer overflow in read/write ioctls
2 parents 6a23ae0 + 97315e7 commit e97c618

File tree

6 files changed

+12
-9
lines changed

6 files changed

+12
-9
lines changed

drivers/mtd/mtdchar.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,7 @@ mtdchar_write_ioctl(struct mtd_info *mtd, struct mtd_write_req __user *argp)
599599
uint8_t *datbuf = NULL, *oobbuf = NULL;
600600
size_t datbuf_len, oobbuf_len;
601601
int ret = 0;
602+
u64 end;
602603

603604
if (copy_from_user(&req, argp, sizeof(req)))
604605
return -EFAULT;
@@ -618,7 +619,7 @@ mtdchar_write_ioctl(struct mtd_info *mtd, struct mtd_write_req __user *argp)
618619
req.len &= 0xffffffff;
619620
req.ooblen &= 0xffffffff;
620621

621-
if (req.start + req.len > mtd->size)
622+
if (check_add_overflow(req.start, req.len, &end) || end > mtd->size)
622623
return -EINVAL;
623624

624625
datbuf_len = min_t(size_t, req.len, mtd->erasesize);
@@ -698,6 +699,7 @@ mtdchar_read_ioctl(struct mtd_info *mtd, struct mtd_read_req __user *argp)
698699
size_t datbuf_len, oobbuf_len;
699700
size_t orig_len, orig_ooblen;
700701
int ret = 0;
702+
u64 end;
701703

702704
if (copy_from_user(&req, argp, sizeof(req)))
703705
return -EFAULT;
@@ -724,7 +726,7 @@ mtdchar_read_ioctl(struct mtd_info *mtd, struct mtd_read_req __user *argp)
724726
req.len &= 0xffffffff;
725727
req.ooblen &= 0xffffffff;
726728

727-
if (req.start + req.len > mtd->size) {
729+
if (check_add_overflow(req.start, req.len, &end) || end > mtd->size) {
728730
ret = -EINVAL;
729731
goto out;
730732
}

drivers/mtd/nand/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ config MTD_NAND_ECC_MEDIATEK
6363

6464
config MTD_NAND_ECC_REALTEK
6565
tristate "Realtek RTL93xx hardware ECC engine"
66-
depends on HAS_IOMEM
66+
depends on HAS_IOMEM && HAS_DMA
6767
depends on MACH_REALTEK_RTL || COMPILE_TEST
6868
select MTD_NAND_ECC
6969
help

drivers/mtd/nand/ecc-realtek.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ static void rtl_ecc_cleanup_ctx(struct nand_device *nand)
380380
nand_ecc_cleanup_req_tweaking(&ctx->req_ctx);
381381
}
382382

383-
static struct nand_ecc_engine_ops rtl_ecc_engine_ops = {
383+
static const struct nand_ecc_engine_ops rtl_ecc_engine_ops = {
384384
.init_ctx = rtl_ecc_init_ctx,
385385
.cleanup_ctx = rtl_ecc_cleanup_ctx,
386386
.prepare_io_req = rtl_ecc_prepare_io_req,
@@ -418,8 +418,8 @@ static int rtl_ecc_probe(struct platform_device *pdev)
418418

419419
rtlc->buf = dma_alloc_noncoherent(dev, RTL_ECC_DMA_SIZE, &rtlc->buf_dma,
420420
DMA_BIDIRECTIONAL, GFP_KERNEL);
421-
if (IS_ERR(rtlc->buf))
422-
return PTR_ERR(rtlc->buf);
421+
if (!rtlc->buf)
422+
return -ENOMEM;
423423

424424
rtlc->dev = dev;
425425
rtlc->engine.dev = dev;

drivers/mtd/nand/onenand/onenand_samsung.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,7 @@ static int s3c_onenand_probe(struct platform_device *pdev)
906906
err = devm_request_irq(&pdev->dev, r->start,
907907
s5pc110_onenand_irq,
908908
IRQF_SHARED, "onenand",
909-
&onenand);
909+
onenand);
910910
if (err) {
911911
dev_err(&pdev->dev, "failed to get irq\n");
912912
return err;

drivers/mtd/nand/raw/cadence-nand-controller.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2871,7 +2871,7 @@ cadence_nand_irq_cleanup(int irqnum, struct cdns_nand_ctrl *cdns_ctrl)
28712871
static int cadence_nand_init(struct cdns_nand_ctrl *cdns_ctrl)
28722872
{
28732873
dma_cap_mask_t mask;
2874-
struct dma_device *dma_dev = cdns_ctrl->dmac->device;
2874+
struct dma_device *dma_dev;
28752875
int ret;
28762876

28772877
cdns_ctrl->cdma_desc = dma_alloc_coherent(cdns_ctrl->dev,
@@ -2915,6 +2915,7 @@ static int cadence_nand_init(struct cdns_nand_ctrl *cdns_ctrl)
29152915
}
29162916
}
29172917

2918+
dma_dev = cdns_ctrl->dmac->device;
29182919
cdns_ctrl->io.iova_dma = dma_map_resource(dma_dev->dev, cdns_ctrl->io.dma,
29192920
cdns_ctrl->io.size,
29202921
DMA_BIDIRECTIONAL, 0);

drivers/mtd/nand/spi/fmsh.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static const struct spinand_info fmsh_spinand_table[] = {
5858
SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
5959
&write_cache_variants,
6060
&update_cache_variants),
61-
SPINAND_HAS_QE_BIT,
61+
0,
6262
SPINAND_ECCINFO(&fm25s01a_ooblayout, NULL)),
6363
};
6464

0 commit comments

Comments
 (0)