v3 --> v4
1. Merge patch 1 and 2 into one:
https://lkml.org/lkml/2020/8/19/1464 Patch 1
https://lkml.org/lkml/2020/8/19/1468 Patch 2
2. The part from patch 1 was reviewed by Oliver O'Halloran
Zhen Lei (1):
libnvdimm: fix memory leaks in of_pmem.c
drivers/nvd
xes: 49bddc73d15c ("libnvdimm/of_pmem: Provide a unique name for bus
provider")
Signed-off-by: Zhen Lei
Reviewed-by: Oliver O'Halloran
---
drivers/nvdimm/of_pmem.c | 7 +++
1 file changed, 7 insertions(+)
diff --git a/drivers/nvdimm/of_pmem.c b/drivers/nvdimm/of_pmem.c
index 10
I found a memleak when I learned the drivers/nvdimm code today. And I also
added a sanity check for priv->bus_desc.provider_name, because strdup()
maybe failed. Patch 3 is a trivial source code optimization.
Zhen Lei (3):
libnvdimm: fix memleak in of_pmem.c
libnvdimm: add sanity ch
kstrdup() may return NULL because of no memory, check it.
Signed-off-by: Zhen Lei
---
drivers/nvdimm/of_pmem.c | 5 +
1 file changed, 5 insertions(+)
diff --git a/drivers/nvdimm/of_pmem.c b/drivers/nvdimm/of_pmem.c
index 1292ffca7b2ecc0..13c4c274ca6ea88 100644
--- a/drivers/nvdimm
The memory priv->bus_desc.provider_name allocated by kstrdup() should be
freed.
Signed-off-by: Zhen Lei
---
drivers/nvdimm/of_pmem.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/nvdimm/of_pmem.c b/drivers/nvdimm/of_pmem.c
index 10dbdcdfb9ce913..1292ffca7b2ecc0 100
hing has changed. So it's
just source code level optimization, make us can read it faster.
Signed-off-by: Zhen Lei
---
drivers/nvdimm/bus.c | 7 +++
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
index 955265656b96c73..1d89114cb6ab9
kstrdup() may return NULL because of no memory, check it.
Fixes: 49bddc73d15c ("libnvdimm/of_pmem: Provide a unique name for bus
provider")
Signed-off-by: Zhen Lei
---
drivers/nvdimm/of_pmem.c | 5 +
1 file changed, 5 insertions(+)
diff --git a/drivers/nvdimm/of_pmem.c b/driv
The memory priv->bus_desc.provider_name allocated by kstrdup() is not
freed correctly.
Fixes: 49bddc73d15c ("libnvdimm/of_pmem: Provide a unique name for bus
provider")
Signed-off-by: Zhen Lei
---
drivers/nvdimm/of_pmem.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/d
ecause strdup()
maybe failed. Patch 3 is a trivial source code optimization.
Zhen Lei (4):
libnvdimm: fix memmory leaks in of_pmem.c
libnvdimm: add sanity check for provider_name in
of_pmem_region_probe()
libnvdimm/bus: simplify walk_to_nvdimm_bus()
libnvdimm/region: reduce an unnec
hing has changed. So it's
just source code level optimization, make us can read it faster.
Signed-off-by: Zhen Lei
---
drivers/nvdimm/bus.c | 7 +++
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
index 955265656b96c73..1d89114cb6ab9
The "else" branch can only be entered when ndr_desc->flush is NULL. After
replaced "NULL" with "ndr_desc->flush", we will find that the statements
in "if..else.." are the same.
No functional change.
Signed-off-by: Zhen Lei
---
drivers/nvdimm/region
hat means, the kzalloc() in badrange_add() or
alloc_and_append_badrange_entry() can be replaced with kmalloc(), because
the zero initialization is not required.
Signed-off-by: Zhen Lei
---
drivers/nvdimm/badrange.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/nvdimm/badrange.c b/drivers
lock
protection.
Fixes: b3b454f694db ("libnvdimm: fix clear poison locking with spinlock ...")
Signed-off-by: Zhen Lei
---
drivers/nvdimm/badrange.c | 22 --
1 file changed, 8 insertions(+), 14 deletions(-)
diff --git a/drivers/nvdimm/badrange.c b/drivers/nvdimm
When I learned the code of drivers/nvdimm, I found some places can be improved.
Zhen Lei (4):
libnvdimm: remove redundant list_empty() check in badrange.c
libnvdimm: eliminate a meaningless spinlock operation
libnvdimm: eliminate two unnecessary zero initializations in
badrange.c
size.
Before:
textdata bss dec hex filename
417493697 16 45462b196 drivers/nvdimm/namespace_devs.o
After:
textdata bss dec hex filename
416533697 16 45366b136 drivers/nvdimm/namespace_devs.o
Signed-off-by: Zhen Lei
---
driver
list_for_each_entry() to do it.
Signed-off-by: Zhen Lei
---
drivers/nvdimm/badrange.c | 10 --
1 file changed, 10 deletions(-)
diff --git a/drivers/nvdimm/badrange.c b/drivers/nvdimm/badrange.c
index b9eeefa27e3a507..9fdba8c43e8605e 100644
--- a/drivers/nvdimm/badrange.c
+++ b/drivers/nvdimm/badrange.c
desc.provider_name, because strdup()
maybe failed. Patch 3 is a trivial source code optimization.
Zhen Lei (7):
libnvdimm: fix memory leaks in of_pmem.c
libnvdimm: add sanity check for provider_name in
of_pmem_region_probe()
libnvdimm: simplify walk_to_nvdimm_bus()
libnvdimm: reduce an
comes the same to 1).
So the above code snippet can be reduced to one statement:
nd_region->flush = ndr_desc->flush;
No functional change.
Signed-off-by: Zhen Lei
---
drivers/nvdimm/region_devs.c | 5 +
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/nvd
Return as soon as nvdimm_bus device has been found, make us no need to
check "dev" or "!dev" in subsequent code.
No functional change.
Signed-off-by: Zhen Lei
---
drivers/nvdimm/bus.c | 7 +++
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/nv
The type of "nfree" is u32, so "nfree - 1" can only be overflowed when
"nfree" is zero. Replace "if (nfree - 1 > nfree)" with "if (nfree == 0)"
seems more clear. And remove the assignment "nfree = 0", no need for it.
Signed-off-
kstrdup() may return NULL because of no memory, check it.
Fixes: 49bddc73d15c ("libnvdimm/of_pmem: Provide a unique name for bus
provider")
Signed-off-by: Zhen Lei
---
drivers/nvdimm/of_pmem.c | 5 +
1 file changed, 5 insertions(+)
diff --git a/drivers/nvdimm/of_pmem.c b/driv
Currently, in the last error path of of_pmem_region_probe() and in
of_pmem_region_remove(), free the memory allocated by kstrdup() is
missing. Add kfree(priv->bus_desc.provider_name) to fix it.
Fixes: 49bddc73d15c ("libnvdimm/of_pmem: Provide a unique name for bus
provider")
Signed
Move EXPORT_SYMBOL_GPL(nvdimm_flush) close to nvdimm_flush(), currently
it's near to generic_nvdimm_flush().
Signed-off-by: Zhen Lei
---
drivers/nvdimm/region_devs.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c
zeof(void *);
}
Obviously, the above code snippet can be reduced to one statement:
flush_data_size += (nvdimm->num_flush + 1) * sizeof(void *);
No functional change.
Signed-off-by: Zhen Lei
---
drivers/nvdimm/region_devs.c | 5 +
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/dr
The resources allocated by request_mem_region() is better to use
release_mem_region() to free. These two functions are paired.
Signed-off-by: Zhen Lei
---
drivers/dax/kmem.c | 6 ++
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/dax/kmem.c b/drivers/dax/kmem.c
index
t; with "ndr_desc->flush" at 2), we will find that
it becomes the same to 1).
So the above code snippet can be reduced to one statement:
nd_region->flush = ndr_desc->flush;
No functional change.
Signed-off-by: Zhen Lei
---
v1 --> v2:
1. Only the title and description are modi
96 drivers/nvdimm/namespace_devs.o
After:
textdata bss dec hex filename
416533697 16 45366b136 drivers/nvdimm/namespace_devs.o
Signed-off-by: Zhen Lei
---
v1 --> v2:
1. Only the title and description are modified.
v1:
https://lore.kernel.org/patchwork/
eaningless.
Because the static function add_badrange() is only called by
badrange_add(), so move its content into badrange_add() then delete it.
By the way, move "kfree(bre_new)" out of the lock protection, it really
doesn't need.
Fixes: b3b454f694db ("libnvdimm: fix clear poison l
v1 --> v2:
1. Only the titles and descriptions are modified.
v1:
https://lore.kernel.org/patchwork/cover/1292582/Patch 1-2
Zhen Lei (2):
libnvdimm/badrange: remove two redundant list_empty() branches
libnvdimm/badrange: eliminate a meaningless spinlock operation
drivers/nvd
()
do things-B //can only be entered if !list_empty()
3) do things-A
return Y;
It's very clear that, the processing result after deleting 1) is the same
as that before deleting 1).
So delete 1) to simplify code.
Signed-off-by: Zhen Lei
---
drivers/nvdimm/badrange.c | 10
Move EXPORT_SYMBOL_GPL(nvdimm_flush) close to nvdimm_flush(), currently
it's near to generic_nvdimm_flush().
Signed-off-by: Zhen Lei
Reviewed-by: Pankaj Gupta
---
v1 --> v2
1. add "Reviewed-by: Pankaj Gupta "
v1:
https://lkml.org/lkml/2020/8/20/904
drivers/nvdimm/region_devs
The type of "nfree" is u32, so "nfree - 1" can only be overflowed when
"nfree" is zero. Replace "if (nfree - 1 > nfree)" with "if (nfree == 0)"
seems more clear. And remove the assignment "nfree = 0", no need for it.
Signed-off-b
96 drivers/nvdimm/namespace_devs.o
After:
textdata bss dec hex filename
416533697 16 45366b136 drivers/nvdimm/namespace_devs.o
Signed-off-by: Zhen Lei
---
v1 --> v2:
1. Only the title and description are modified.
v1:
https://lore.kernel.org/patchwork/
v1 --> v2:
In v1, I use the "goto" statement to merge two identical __release_region()
calls.
However, the new patch https://lkml.org/lkml/2020/12/18/735 deletes one of
them, the
"goto" becomes worthless. So when krealloc() failed, directly call
__release_region()
and re
Swap the calling sequence of krealloc() and __request_region(), call the
latter first. In this way, the value of dev_dax->nr_range does not need to
be considered when __request_region() failed.
Signed-off-by: Zhen Lei
---
drivers/dax/bus.c | 20 ++--
1 file changed, 6 inserti
Swap the calling sequence of krealloc() and __request_region(), call the
latter first. In this way, the value of dev_dax->nr_range does not need to
be considered when __request_region() failed.
Signed-off-by: Zhen Lei
---
drivers/dax/bus.c | 29 -
1 file changed,
After we have done the alignment check for the length of each range, the
alignment check for dev_dax_size(dev_dax) is no longer needed, because it
get the sum of the length of each range.
Signed-off-by: Zhen Lei
---
drivers/dax/bus.c | 7 ---
1 file changed, 7 deletions(-)
diff --git
The badrange to be reported should always cover mce->addr.
Signed-off-by: Zhen Lei
---
drivers/acpi/nfit/mce.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/acpi/nfit/mce.c b/drivers/acpi/nfit/mce.c
index ee8d9973f60b..053e719c7bea 100644
--- a/drivers/acpi/n
Make sure the badrange to be reported can always cover mce->addr.
Fixes: 9ffd6350a103 ("nfit: don't start a full scrub by default for an MCE")
Signed-off-by: Zhen Lei
Reviewed-by: Vishal Verma
---
drivers/acpi/nfit/mce.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-
v1 --> v2:
Modified the title and description of the patch.
Zhen Lei (1):
acpi/nfit: fix badrange insertion in nfit_handle_mce()
drivers/acpi/nfit/mce.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--
2.26.0.106.g9fadedd
___
Linux-nvd
The ACPI_ALLOCATE() does not zero the "buf", so when the condition
"integer->type != ACPI_TYPE_INTEGER" in int_to_buf() is met, the result
is unpredictable in acpi_nfit_ctl().
Signed-off-by: Zhen Lei
---
drivers/acpi/nfit/core.c | 9 +
1 file changed, 5 ins
41 matches
Mail list logo