Skip to content

Commit

Permalink
target: fix NULL pointer dereference bug alloc_page() fails to get me…
Browse files Browse the repository at this point in the history
…mory

I am hitting this bug when the target is low in memory that fails the
alloc_page() for the newly submitted command. This is a sort of off-by-one
bug causing NULL pointer dereference in __free_page() since 'i' here is
really the counter of total pages that have been successfully allocated here.

Signed-off-by: Yi Zou <yi.zou@intel.com>
Cc: Andy Grover <agrover@redhat.com>
Cc: Nicholas Bellinger <nab@linux-iscsi.org>
Cc: Open-FCoE.org <devel@open-fcoe.org>
Cc: stable@vger.kernel.org
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
  • Loading branch information
Yi Zou authored and Nicholas Bellinger committed Aug 17, 2012
1 parent 1fa8f45 commit d0e27c8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/target/target_core_transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -2294,9 +2294,9 @@ transport_generic_get_mem(struct se_cmd *cmd)
return 0;

out:
while (i >= 0) {
__free_page(sg_page(&cmd->t_data_sg[i]));
while (i > 0) {
i--;
__free_page(sg_page(&cmd->t_data_sg[i]));
}
kfree(cmd->t_data_sg);
cmd->t_data_sg = NULL;
Expand Down

0 comments on commit d0e27c8

Please sign in to comment.