hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I9K0H3
--------------------------------
In __blkdev_issue_discard(), q->limits.discard_granularity is read
multi times.
WARN_ON_ONCE(!q->limits.discard_granularity) [1]
...
q->limits.discard_granularity >> SECTOR_SHIFT [2]
...
bio_aligned_discard_max_sectors [3]
It can be changed to 0 after check [1], such as submitting ioctl
'LOOP_SET_STATUS'. This is undesirable. If 'discard_granularity' is set
to 0, BUG_ON might be triggered and the loop of 'while(nr_sects)' will
never exit(see fixes commit). Fix it by checking 'req_sects' before
submit io, return error code directly if it is 0.
Fixes: b35fd7422c2f ("block: check queue's limits.discard_granularity in __blkdev_issue_discard()")
Signed-off-by: Li Nan <linan122(a)huawei.com>
---
block/blk-lib.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/block/blk-lib.c b/block/blk-lib.c
index e90614fd8d6a..59ff99bc4698 100644
--- a/block/blk-lib.c
+++ b/block/blk-lib.c
@@ -27,7 +27,7 @@ int __blkdev_issue_discard(struct block_device *bdev, sector_t sector,
struct bio **biop)
{
struct request_queue *q = bdev_get_queue(bdev);
- struct bio *bio = *biop;
+ struct bio *bio = NULL;
unsigned int op;
sector_t bs_mask, part_offset = 0;
@@ -92,6 +92,17 @@ int __blkdev_issue_discard(struct block_device *bdev, sector_t sector,
req_sects = min_t(sector_t, nr_sects,
granularity_aligned_lba - sector_mapped);
+ if (!req_sects) {
+ /* just put the bio allocated in this function */
+ if (bio) {
+ bio_io_error(bio);
+ bio_put(bio);
+ }
+ return -EOPNOTSUPP;
+ }
+ if (!bio)
+ bio = *biop;
+
WARN_ON_ONCE((req_sects << 9) > UINT_MAX);
bio = blk_next_bio(bio, 0, gfp_mask);
--
2.39.2
From: Andy Shevchenko <andriy.shevchenko(a)linux.intel.com>
stable inclusion
from stable-v4.19.311
commit 787e2620d1574196f10193a7c3693d95958254cb
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IA6BE4
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id…
--------------------------------
[ Upstream commit 73b5a5c00be39e23b194bad10e1ea8bb73eee176 ]
It seems a copy&paste mistake that suspend callback removes the GPIO
device. There is no counterpart of this action, means once suspended
there is no more GPIO device available untile full unbind-bind cycle
is performed. Remove suspicious GPIO device removal in suspend.
Fixes: d0aeaa83f0b0 ("serial: exar: split out the exar code from 8250_pci")
Signed-off-by: Andy Shevchenko <andriy.shevchenko(a)linux.intel.com>
Link: https://lore.kernel.org/r/20240219150627.2101198-2-andriy.shevchenko@linux.…
Signed-off-by: Greg Kroah-Hartman <gregkh(a)linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal(a)kernel.org>
Signed-off-by: Yi Yang <yiyang13(a)huawei.com>
---
drivers/tty/serial/8250/8250_exar.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c
index 18a373d89480..c1444b140015 100644
--- a/drivers/tty/serial/8250/8250_exar.c
+++ b/drivers/tty/serial/8250/8250_exar.c
@@ -535,6 +535,7 @@ static void exar_pci_remove(struct pci_dev *pcidev)
for (i = 0; i < priv->nr; i++)
serial8250_unregister_port(priv->line[i]);
+ /* Ensure that every init quirk is properly torn down */
if (priv->board->exit)
priv->board->exit(pcidev);
}
@@ -549,10 +550,6 @@ static int __maybe_unused exar_suspend(struct device *dev)
if (priv->line[i] >= 0)
serial8250_suspend_port(priv->line[i]);
- /* Ensure that every init quirk is properly torn down */
- if (priv->board->exit)
- priv->board->exit(pcidev);
-
return 0;
}
--
2.25.1