lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20200915112315.310d89c8@xps13>
Date:   Tue, 15 Sep 2020 11:23:15 +0200
From:   Miquel Raynal <miquel.raynal@...tlin.com>
To:     Yifeng Zhao <yifeng.zhao@...k-chips.com>
Cc:     richard@....at, vigneshr@...com, robh+dt@...nel.org,
        devicetree@...r.kernel.org, linux-mtd@...ts.infradead.org,
        heiko@...ech.de, linux-rockchip@...ts.infradead.org,
        linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v8 2/8] mtd: rawnand: rockchip: NFC drivers for RK3308,
 RK2928 and others


Miquel Raynal <miquel.raynal@...tlin.com> wrote on Tue, 15 Sep 2020
10:07:28 +0200:

> Hi Yifeng,
> 
> I am very sorry for the delay it took me to review this driver, but
> there are still some small incoherences IMHO, see below.

One last important comment below

> > +static int rk_nfc_attach_chip(struct nand_chip *chip)
> > +{
> > +	struct mtd_info *mtd = nand_to_mtd(chip);
> > +	struct device *dev = mtd->dev.parent;
> > +	struct rk_nfc *nfc = nand_get_controller_data(chip);
> > +	struct rk_nfc_nand_chip *rknand = to_rknand(chip);
> > +	struct nand_ecc_ctrl *ecc = &chip->ecc;
> > +	int len;
> > +	int ret;
> > +
> > +	if (chip->options & NAND_BUSWIDTH_16) {
> > +		dev_err(dev, "16 bits bus width not supported");
> > +		return -EINVAL;
> > +	}
> > +
> > +	if (ecc->mode != NAND_ECC_HW)
> > +		return 0;
> > +
> > +	ret = rk_nfc_ecc_init(dev, mtd);
> > +	if (ret)
> > +		return ret;
> > +	rknand->spare_per_sector = ecc->bytes + NFC_SYS_DATA_SIZE;
> > +	rknand->metadata_size = NFC_SYS_DATA_SIZE * ecc->steps;
> > +
> > +	if (rknand->metadata_size < NFC_SYS_DATA_SIZE + 2) {
> > +		dev_err(dev,
> > +			"Driver needs at least %d bytes of meta data\n",
> > +			NFC_SYS_DATA_SIZE + 2);
> > +		return -EIO;
> > +	}
> > +	/* Check buffer first, avoid duplicate alloc buffer. */
> > +	if (nfc->buffer)
> > +		return 0;  
> 
> You can't do that this way: what if the first mtd to be registered uses
> a smaller page size than the second?
> 
> > +
> > +	len = mtd->writesize + mtd->oobsize;
> > +	nfc->buffer = devm_kzalloc(dev, len, GFP_KERNEL | GFP_DMA);

I don't think this fits your purpose. You should probably allocate with
kzalloc or perhaps dma_alloc*.

Then, you'll also have to free this memory.

> > +	if (!nfc->buffer)
> > +		return -ENOMEM;
> > +
> > +	nfc->page_buf = nfc->buffer;
> > +	len = ecc->steps * NFC_MAX_OOB_PER_STEP;
> > +	nfc->oob_buf = devm_kzalloc(dev, len, GFP_KERNEL | GFP_DMA);
> > +	if (!nfc->oob_buf) {
> > +		nfc->buffer = NULL;
> > +		nfc->oob_buf = NULL;  
> 
> I don't think this is needed
> 
> > +		return -ENOMEM;
> > +	}
> > +
> > +	chip->ecc.write_page_raw = rk_nfc_write_page_raw;
> > +	chip->ecc.write_page = rk_nfc_write_page_hwecc;
> > +	chip->ecc.write_oob_raw = rk_nfc_write_oob_std;
> > +	chip->ecc.write_oob = rk_nfc_write_oob_std;
> > +
> > +	chip->ecc.read_page_raw = rk_nfc_read_page_raw;
> > +	chip->ecc.read_page = rk_nfc_read_page_hwecc;
> > +	chip->ecc.read_oob_raw = rk_nfc_read_oob_std;
> > +	chip->ecc.read_oob = rk_nfc_read_oob_std;  
> 
> I don't like the _std prefix, but it should be gone when splitting the
> functions as advised.
> 
> > +
> > +	return 0;
> > +}

Thanks,
Miquèl

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ