From: Hannes Reinecke <hare@suse.de>
To: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Christoph Hellwig <hch@lst.de>,
James Bottomley <james.bottomley@hansenpartnership.com>,
linux-scsi@vger.kernel.org, Hannes Reinecke <hare@suse.de>,
Hannes Reinecke <hare@suse.com>
Subject: [PATCH 2/4] ses: check return code from ses_recv_diag()
Date: Tue, 15 Aug 2017 10:21:41 +0200 [thread overview]
Message-ID: <1502785303-41870-3-git-send-email-hare@suse.de> (raw)
In-Reply-To: <1502785303-41870-1-git-send-email-hare@suse.de>
We should be checking the return code from ses_recv_diag() to
avoid accessing invalid data.
Signed-off-by: Hannes Reinecke <hare@suse.com>
---
drivers/scsi/ses.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c
index a37aec8..fc70c00 100644
--- a/drivers/scsi/ses.c
+++ b/drivers/scsi/ses.c
@@ -179,7 +179,8 @@ static unsigned char *ses_get_page2_descriptor(struct enclosure_device *edev,
unsigned char *type_ptr = ses_dev->page1_types;
unsigned char *desc_ptr = ses_dev->page2 + 8;
- ses_recv_diag(sdev, 2, ses_dev->page2, ses_dev->page2_len);
+ if (ses_recv_diag(sdev, 2, ses_dev->page2, ses_dev->page2_len) < 0)
+ return NULL;
for (i = 0; i < ses_dev->page1_num_types; i++, type_ptr += 4) {
for (j = 0; j < type_ptr[1]; j++) {
--
1.8.5.6
next prev parent reply other threads:[~2017-08-15 8:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-15 8:21 [PATCH 0/4] ses: simple subenclosure support Hannes Reinecke
2017-08-15 8:21 ` [PATCH 1/4] scsi: Fixup ses page check Hannes Reinecke
2017-08-17 0:24 ` Martin K. Petersen
2017-08-15 8:21 ` Hannes Reinecke [this message]
2017-08-15 8:21 ` [PATCH 3/4] ses: Fixup error message 'failed to get diagnostic page 0xffffffea' Hannes Reinecke
2017-08-15 8:21 ` [PATCH 4/4] ses: make page2 support optional Hannes Reinecke
2017-08-17 0:28 ` [PATCH 0/4] ses: simple subenclosure support Martin K. Petersen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1502785303-41870-3-git-send-email-hare@suse.de \
--to=hare@suse.de \
--cc=hare@suse.com \
--cc=hch@lst.de \
--cc=james.bottomley@hansenpartnership.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox