linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [GIT PULL 0/2] lightnvm updates for 5.3
@ 2019-06-21  9:11 Matias Bjørling
  2019-06-21  9:11 ` [GIT PULL 1/2] lightnvm: pblk: fix freeing of merged pages Matias Bjørling
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Matias Bjørling @ 2019-06-21  9:11 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, linux-kernel, Matias Bjørling

Hi Jens,

A couple of patches for the 5.3 window. Geert fixed an uninitialized
pointer bug, and Heiner fixed up a bug when merging bio pages in pblk.

Thank you,
Matias

Geert Uytterhoeven (1):
  lightnvm: fix uninitialized pointer in nvm_remove_tgt()

Heiner Litz (1):
  lightnvm: pblk: fix freeing of merged pages

 drivers/lightnvm/core.c      |  2 +-
 drivers/lightnvm/pblk-core.c | 16 +++++++++-------
 2 files changed, 10 insertions(+), 8 deletions(-)

-- 
2.19.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [GIT PULL 1/2] lightnvm: pblk: fix freeing of merged pages
  2019-06-21  9:11 [GIT PULL 0/2] lightnvm updates for 5.3 Matias Bjørling
@ 2019-06-21  9:11 ` Matias Bjørling
  2019-06-21  9:12 ` [GIT PULL 2/2] lightnvm: fix uninitialized pointer in nvm_remove_tgt() Matias Bjørling
  2019-06-21  9:14 ` [GIT PULL 0/2] lightnvm updates for 5.3 Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Matias Bjørling @ 2019-06-21  9:11 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, linux-kernel, Heiner Litz, Matias Bjørling

From: Heiner Litz <hlitz@ucsc.edu>

bio_add_pc_page() may merge pages when a bio is padded due to a flush.
Fix iteration over the bio to free the correct pages in case of a merge.

Signed-off-by: Heiner Litz <hlitz@ucsc.edu>
Reviewed-by: Javier González <javier@javigon.com>
Signed-off-by: Matias Bjørling <mb@lightnvm.io>
---
 drivers/lightnvm/pblk-core.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c
index 773537804319..f546e6f28b8a 100644
--- a/drivers/lightnvm/pblk-core.c
+++ b/drivers/lightnvm/pblk-core.c
@@ -323,14 +323,16 @@ void pblk_free_rqd(struct pblk *pblk, struct nvm_rq *rqd, int type)
 void pblk_bio_free_pages(struct pblk *pblk, struct bio *bio, int off,
 			 int nr_pages)
 {
-	struct bio_vec bv;
-	int i;
+	struct bio_vec *bv;
+	struct page *page;
+	int i, e, nbv = 0;
 
-	WARN_ON(off + nr_pages != bio->bi_vcnt);
-
-	for (i = off; i < nr_pages + off; i++) {
-		bv = bio->bi_io_vec[i];
-		mempool_free(bv.bv_page, &pblk->page_bio_pool);
+	for (i = 0; i < bio->bi_vcnt; i++) {
+		bv = &bio->bi_io_vec[i];
+		page = bv->bv_page;
+		for (e = 0; e < bv->bv_len; e += PBLK_EXPOSED_PAGE_SIZE, nbv++)
+			if (nbv >= off)
+				mempool_free(page++, &pblk->page_bio_pool);
 	}
 }
 
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [GIT PULL 2/2] lightnvm: fix uninitialized pointer in nvm_remove_tgt()
  2019-06-21  9:11 [GIT PULL 0/2] lightnvm updates for 5.3 Matias Bjørling
  2019-06-21  9:11 ` [GIT PULL 1/2] lightnvm: pblk: fix freeing of merged pages Matias Bjørling
@ 2019-06-21  9:12 ` Matias Bjørling
  2019-06-21  9:14 ` [GIT PULL 0/2] lightnvm updates for 5.3 Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Matias Bjørling @ 2019-06-21  9:12 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, linux-kernel, Geert Uytterhoeven, Matias Bjørling

From: Geert Uytterhoeven <geert@linux-m68k.org>

With gcc 4.1:

    drivers/lightnvm/core.c: In function ‘nvm_remove_tgt’:
    drivers/lightnvm/core.c:510: warning: ‘t’ is used uninitialized in this function

Indeed, if no NVM devices have been registered, t will be an
uninitialized pointer, and may be dereferenced later.  A call to
nvm_remove_tgt() can be triggered from userspace by issuing the
NVM_DEV_REMOVE ioctl on the lightnvm control device.

Fix this by preinitializing t to NULL.

Fixes: 843f2edbdde085b4 ("lightnvm: do not remove instance under global lock")
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Matias Bjørling <mb@lightnvm.io>
---
 drivers/lightnvm/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c
index 7d555b110ecd..a600934fdd9c 100644
--- a/drivers/lightnvm/core.c
+++ b/drivers/lightnvm/core.c
@@ -478,7 +478,7 @@ static void __nvm_remove_target(struct nvm_target *t, bool graceful)
  */
 static int nvm_remove_tgt(struct nvm_ioctl_remove *remove)
 {
-	struct nvm_target *t;
+	struct nvm_target *t = NULL;
 	struct nvm_dev *dev;
 
 	down_read(&nvm_lock);
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [GIT PULL 0/2] lightnvm updates for 5.3
  2019-06-21  9:11 [GIT PULL 0/2] lightnvm updates for 5.3 Matias Bjørling
  2019-06-21  9:11 ` [GIT PULL 1/2] lightnvm: pblk: fix freeing of merged pages Matias Bjørling
  2019-06-21  9:12 ` [GIT PULL 2/2] lightnvm: fix uninitialized pointer in nvm_remove_tgt() Matias Bjørling
@ 2019-06-21  9:14 ` Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2019-06-21  9:14 UTC (permalink / raw)
  To: Matias Bjørling; +Cc: linux-block, linux-kernel

On 6/21/19 3:11 AM, Matias Bjørling wrote:
> Hi Jens,
> 
> A couple of patches for the 5.3 window. Geert fixed an uninitialized
> pointer bug, and Heiner fixed up a bug when merging bio pages in pblk.

Applied, thanks.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-06-21  9:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-21  9:11 [GIT PULL 0/2] lightnvm updates for 5.3 Matias Bjørling
2019-06-21  9:11 ` [GIT PULL 1/2] lightnvm: pblk: fix freeing of merged pages Matias Bjørling
2019-06-21  9:12 ` [GIT PULL 2/2] lightnvm: fix uninitialized pointer in nvm_remove_tgt() Matias Bjørling
2019-06-21  9:14 ` [GIT PULL 0/2] lightnvm updates for 5.3 Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).