@@ -562,36 +562,19 @@ static int p9_check_zc_errors(struct p9_client *c, struct p9_req_t *req,
562
562
563
563
if (!p9_is_proto_dotl (c )) {
564
564
/* Error is reported in string format */
565
- uint16_t len ;
566
- /* 7 = header size for RERROR, 2 is the size of string len ; */
567
- int inline_len = in_hdrlen - ( 7 + 2 ) ;
565
+ int len ;
566
+ /* 7 = header size for RERROR; */
567
+ int inline_len = in_hdrlen - 7 ;
568
568
569
- /* Read the size of error string */
570
- err = p9pdu_readf (req -> rc , c -> proto_version , "w" , & len );
571
- if (err )
572
- goto out_err ;
573
-
574
- ename = kmalloc (len + 1 , GFP_NOFS );
575
- if (!ename ) {
576
- err = - ENOMEM ;
569
+ len = req -> rc -> size - req -> rc -> offset ;
570
+ if (len > (P9_ZC_HDR_SZ - 7 )) {
571
+ err = - EFAULT ;
577
572
goto out_err ;
578
573
}
579
- if (len <= inline_len ) {
580
- /* We have error in protocol buffer itself */
581
- if (pdu_read (req -> rc , ename , len )) {
582
- err = - EFAULT ;
583
- goto out_free ;
584
574
585
- }
586
- } else {
587
- /*
588
- * Part of the data is in user space buffer.
589
- */
590
- if (pdu_read (req -> rc , ename , inline_len )) {
591
- err = - EFAULT ;
592
- goto out_free ;
593
-
594
- }
575
+ ename = & req -> rc -> sdata [req -> rc -> offset ];
576
+ if (len > inline_len ) {
577
+ /* We have error in external buffer */
595
578
if (kern_buf ) {
596
579
memcpy (ename + inline_len , uidata ,
597
580
len - inline_len );
@@ -600,19 +583,19 @@ static int p9_check_zc_errors(struct p9_client *c, struct p9_req_t *req,
600
583
uidata , len - inline_len );
601
584
if (err ) {
602
585
err = - EFAULT ;
603
- goto out_free ;
586
+ goto out_err ;
604
587
}
605
588
}
606
589
}
607
- ename [ len ] = 0 ;
608
- if ( p9_is_proto_dotu ( c )) {
609
- /* For dotu we also have error code */
610
- err = p9pdu_readf ( req -> rc ,
611
- c -> proto_version , "d" , & ecode ) ;
612
- if ( err )
613
- goto out_free ;
590
+ ename = NULL ;
591
+ err = p9pdu_readf ( req -> rc , c -> proto_version , "s?d" ,
592
+ & ename , & ecode );
593
+ if ( err )
594
+ goto out_err ;
595
+
596
+ if ( p9_is_proto_dotu ( c ))
614
597
err = - ecode ;
615
- }
598
+
616
599
if (!err || !IS_ERR_VALUE (err )) {
617
600
err = p9_errstr2errno (ename , strlen (ename ));
618
601
@@ -628,8 +611,6 @@ static int p9_check_zc_errors(struct p9_client *c, struct p9_req_t *req,
628
611
}
629
612
return err ;
630
613
631
- out_free :
632
- kfree (ename );
633
614
out_err :
634
615
p9_debug (P9_DEBUG_ERROR , "couldn't parse error%d\n" , err );
635
616
return err ;
0 commit comments