]> nv-tegra.nvidia Code Review - linux-2.6.git/commitdiff
sata_sil24: memset() overflow
authorDan Carpenter <error27@gmail.com>
Wed, 9 Jun 2010 12:01:54 +0000 (14:01 +0200)
committerJeff Garzik <jgarzik@redhat.com>
Thu, 10 Jun 2010 20:06:33 +0000 (16:06 -0400)
cb->atapi.cdb is an array of 16 u8 elements.  The call too memset()
would set the first part of the sge array to zero as well.  It's not
a packed struct.

This one has been around for five years.  I found it with Smatch.  I
think the reason no one has seen it before is because we normally call
sil24_fill_sg() and that overwrites sge with proper information?

Signed-off-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
drivers/ata/sata_sil24.c

index 70b58fe9e5b109cf68925c0d2c7568233bf0583b..a7f0139c3aae4743d1e7f33fb051b6131f24122c 100644 (file)
@@ -865,7 +865,7 @@ static void sil24_qc_prep(struct ata_queued_cmd *qc)
        } else {
                prb = &cb->atapi.prb;
                sge = cb->atapi.sge;
-               memset(cb->atapi.cdb, 0, 32);
+               memset(cb->atapi.cdb, 0, sizeof(cb->atapi.cdb));
                memcpy(cb->atapi.cdb, qc->cdb, qc->dev->cdb_len);
 
                if (ata_is_data(qc->tf.protocol)) {