Skip to content

Commit

Permalink
rsxx: enable error return of rsxx_eeh_save_issued_dmas()
Browse files Browse the repository at this point in the history
Commit d8d595d introduced a bug where we did not check for a NULL
return from kmalloc(). Make rsxx_eeh_save_issued_dmas() return an
error for that case, and make the callers handle that.

Signed-off-by: Philip J Kelleher <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Philip J Kelleher authored and axboe committed Mar 26, 2013
1 parent d8d595d commit 4dcaf47
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
19 changes: 16 additions & 3 deletions drivers/block/rsxx/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,11 @@ static int card_shutdown(struct rsxx_cardinfo *card)
return 0;
}

static void rsxx_eeh_frozen(struct pci_dev *dev)
static int rsxx_eeh_frozen(struct pci_dev *dev)
{
struct rsxx_cardinfo *card = pci_get_drvdata(dev);
int i;
int st;

dev_warn(&dev->dev, "IBM FlashSystem PCI: preparing for slot reset.\n");

Expand All @@ -342,7 +343,9 @@ static void rsxx_eeh_frozen(struct pci_dev *dev)

pci_disable_device(dev);

rsxx_eeh_save_issued_dmas(card);
st = rsxx_eeh_save_issued_dmas(card);
if (st)
return st;

rsxx_eeh_save_issued_creg(card);

Expand All @@ -356,6 +359,8 @@ static void rsxx_eeh_frozen(struct pci_dev *dev)
card->ctrl[i].cmd.buf,
card->ctrl[i].cmd.dma_addr);
}

return 0;
}

static void rsxx_eeh_failure(struct pci_dev *dev)
Expand Down Expand Up @@ -399,6 +404,8 @@ static int rsxx_eeh_fifo_flush_poll(struct rsxx_cardinfo *card)
static pci_ers_result_t rsxx_error_detected(struct pci_dev *dev,
enum pci_channel_state error)
{
int st;

if (dev->revision < RSXX_EEH_SUPPORT)
return PCI_ERS_RESULT_NONE;

Expand All @@ -407,7 +414,13 @@ static pci_ers_result_t rsxx_error_detected(struct pci_dev *dev,
return PCI_ERS_RESULT_DISCONNECT;
}

rsxx_eeh_frozen(dev);
st = rsxx_eeh_frozen(dev);
if (st) {
dev_err(&dev->dev, "Slot reset setup failed\n");
rsxx_eeh_failure(dev);
return PCI_ERS_RESULT_DISCONNECT;
}

return PCI_ERS_RESULT_NEED_RESET;
}

Expand Down
6 changes: 5 additions & 1 deletion drivers/block/rsxx/dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,7 @@ void rsxx_dma_destroy(struct rsxx_cardinfo *card)
}
}

void rsxx_eeh_save_issued_dmas(struct rsxx_cardinfo *card)
int rsxx_eeh_save_issued_dmas(struct rsxx_cardinfo *card)
{
int i;
int j;
Expand All @@ -990,6 +990,8 @@ void rsxx_eeh_save_issued_dmas(struct rsxx_cardinfo *card)

issued_dmas = kzalloc(sizeof(*issued_dmas) * card->n_targets,
GFP_KERNEL);
if (!issued_dmas)
return -ENOMEM;

for (i = 0; i < card->n_targets; i++) {
INIT_LIST_HEAD(&issued_dmas[i]);
Expand Down Expand Up @@ -1030,6 +1032,8 @@ void rsxx_eeh_save_issued_dmas(struct rsxx_cardinfo *card)
}

kfree(issued_dmas);

return 0;
}

void rsxx_eeh_cancel_dmas(struct rsxx_cardinfo *card)
Expand Down
2 changes: 1 addition & 1 deletion drivers/block/rsxx/rsxx_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ int rsxx_dma_queue_bio(struct rsxx_cardinfo *card,
rsxx_dma_cb cb,
void *cb_data);
int rsxx_hw_buffers_init(struct pci_dev *dev, struct rsxx_dma_ctrl *ctrl);
void rsxx_eeh_save_issued_dmas(struct rsxx_cardinfo *card);
int rsxx_eeh_save_issued_dmas(struct rsxx_cardinfo *card);
void rsxx_eeh_cancel_dmas(struct rsxx_cardinfo *card);
int rsxx_eeh_remap_dmas(struct rsxx_cardinfo *card);

Expand Down

0 comments on commit 4dcaf47

Please sign in to comment.